Skip to content

fix: allow "unlimited" for integer keep-* flags in JSON schema - #683

Merged
creativeprojects merged 2 commits into
creativeprojects:masterfrom
ericbyz:fix/keep-unlimited-jsonschema
Nov 18, 2026
Merged

creativeprojects merged 2 commits into
creativeprojects:masterfrom
ericbyz:fix/keep-unlimited-jsonschema

Conversation

@ericbyz

@ericbyz ericbyz commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #449

restic accepts unlimited as an alternative to a count for the integer keep-* retention flags (as documented in the restic help text), but the generated JSON schema only allowed integers, so editors flagged valid configurations like:

version: 2
profiles:
  default:
    retention:
      keep-daily: unlimited

Changes

  • config: for integer keep-* restic flags, the property info now also allows the string value unlimited (other integer flags such as limit-download are unchanged).
  • config/jsonschema: enum values are now filtered per schema type, mirroring how defaults and examples are already filtered. Without this, the unlimited enum would leak into the integer branch of the schema and make every numeric value invalid.

The generated schema renders keep-daily as:

{
  "oneOf": [
    { "type": "integer" },
    { "type": "string", "enum": ["unlimited"] }
  ]
}

Testing

  • added unit tests for the property info detection (integer keep-* vs limit-download vs duration keep-within)
  • added a schema test asserting the rendered oneOf for keep-daily in the retention section, and that limit-download stays integer-only
  • updated the Enum case of TestConfigureBasicInfo for the per-type filtering
  • go test ./config/... passes; golangci-lint run ./config/... (v2.12.2) reports 0 issues

ericbyz and others added 2 commits October 9, 2026 10:53
restic accepts "unlimited" as an alternative to a count for the integer
keep-* retention flags, but the generated JSON schema only allowed
integers. Allow the string value "unlimited" for these flags, and filter
enum values per schema type so the "unlimited" enum only applies to the
string branch of the schema.
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Integer options named with the keep- prefix now accept the string value "unlimited". JSON schema generation filters enum values by schema type and represents keep-daily with integer and string variants.

Changes

Keep flag schema support

Layer / File(s) Summary
Add unlimited to keep-flag metadata
config/info.go, config/info_test.go
Integer options prefixed with keep- also accept strings and expose "unlimited" as an enum value. Tests cover keep-daily, limit-download, and keep-within.
Filter enum values by schema type
config/jsonschema/schema.go, config/jsonschema/schema_test.go
Schema enum values are filtered for compatibility with each base type. Tests check typed enum values and the generated schemas for keep-daily and limit-download.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: jkellerer, creativeprojects

Merge Risk: Minimal · up to cefe9

Integer keep-* options in the JSON schema now accept "unlimited" alongside integers, while other integer flags stay integer-only. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: integer keep-* flags in the JSON schema now accept "unlimited". The changeset adds this to the property info and to schema generation, so the title matches the primary…
Description check Passed The description states the problem (the generated schema rejects valid restic values such as keep-daily: unlimited), lists the changes in config and config/jsonschema, and describes the tests added. I…
Linked Issues check Passed Issue #449 requires integer keep-* retention and forget flags to accept the string unlimited, using oneOf or anyOf. At the reviewed head, newResticPropertyInfo in config/info.go sets `mayS…
Out of Scope Changes check Passed All changed files relate to the objective. config/info.go adds the unlimited rule for keep-* integer flags. config/jsonschema/schema.go adds per-type enum filtering, which the new rule require…
Full details: Title check

Explanation

The title names the main change: integer keep-* flags in the JSON schema now accept "unlimited". The changeset adds this to the property info and to schema generation, so the title matches the primary change.

Full details: Description check

Explanation

The description states the problem (the generated schema rejects valid restic values such as keep-daily: unlimited), lists the changes in config and config/jsonschema, and describes the tests added. It matches the changeset.

Full details: Linked Issues check

Explanation

Issue #449 requires integer keep-* retention and forget flags to accept the string unlimited, using oneOf or anyOf. At the reviewed head, newResticPropertyInfo in config/info.go sets mayString = true and enum = ["unlimited"] for any integer option whose name starts with keep-. This is the shared restic property-info path, so it covers every keep-* integer flag, including the forget section. The schema test TestSchemaForKeepFlags asserts the rendered two-variant oneOf for keep-daily in the retention section. The limit-download flag stays integer-only, as the issue does not require otherwise. The change also filters enum values per schema type in config/jsonschema/schema.go, so the unlimited enum does not invalidate the integer branch. The PR does not add a separate test for the v1 schema or the forget section. The shared code path supports coverage of both, but the evidence for v1 is indirect.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the objective. config/info.go adds the unlimited rule for keep-* integer flags. config/jsonschema/schema.go adds per-type enum filtering, which the new rule requires to keep the integer branch valid. config/info_test.go and config/jsonschema/schema_test.go test the new behaviour. The Enum case of TestConfigureBasicInfo is updated to match the per-type filtering. No unrelated change was found in the reviewed diff summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b5044d1-aecf-4009-9714-6a1dd707206b
Commits

Reviewing files that changed from the base of the PR and between afe05d0 and cefe98a.

Files selected for processing: 4

  • config/info.go
  • config/info_test.go
  • config/jsonschema/schema.go
  • config/jsonschema/schema_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@creativeprojects creativeprojects left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!

I like that the AI also tested the generated JSON schema 👍🏻

@creativeprojects
creativeprojects merged commit daeff82 into creativeprojects:master Nov 18, 2026
16 checks passed
@creativeprojects creativeprojects added this to the v0.35.0 milestone Nov 18, 2026
@creativeprojects creativeprojects added the bug Something isn't working label Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.42%. Comparing base (afe05d0) to head (cefe98a).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #683   +/-   ##
=======================================
  Coverage   85.42%   85.42%           
=======================================
  Files         161      161           
  Lines       10396    10399    +3     
=======================================
+ Hits         8880     8883    +3     
  Misses       1516     1516           
Flag Coverage Δ
unittests 83.34% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON schema missing unlimited option for --keep-* flags in the retention and forget profile sections

2 participants