You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: accept unlimited for the keep-* options in the JSON schema - #717
restic's help for --keep-last, --keep-hourly, --keep-daily, --keep-weekly, --keep-monthly and --keep-yearly says "use 'unlimited' to keep all ...". The default for each of these options is 0, so newResticPropertyInfo types them as integer only. Both the v1 and v2 schemas then reject keep-last: unlimited in the forget and retention sections.
This adds a property customizer, next to the existing one for verbose. A restic option whose description offers 'unlimited' may also be a string, and the string must match ^unlimited$. The flags are passed to restic unchanged, so only the schema changes. keep-last in the v2 schema:
# before
{"type": "integer"}
# after
{"oneOf": [{"type": "integer"}, {"type": "string", "minLength": 0, "pattern": "^unlimited$"}]}
This is the oneOf proposed in the issue.
Checks:
TestResticKeepUnlimitedProperty in config/info_customizer_test.go: before the customizer runs, the option is numeric only; after it runs, it is numeric or string with the pattern. An option without 'unlimited' in its description is left alone.
End to end: I ran resticprofile generate --json-schema v2 on master and on this branch, then validated {"forget": {"keep-last": "unlimited", "keep-daily": 7}} with Python jsonschema (Draft 2020-12). Master reports 'unlimited' is not of type 'integer', and this branch reports it valid.
go test -short ./config/... and go vet ./config/ pass.
restic accepts "unlimited" for --keep-last, --keep-daily and the other
keep-* options, and says so in their help, but their default is 0, so
the schema typed them as integer only and editors flagged
keep-last: unlimited as invalid. Let the options whose description
offers 'unlimited' also be a string matching ^unlimited$.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
No actionable comments were generated in the recent review.
Walkthrough
The property customizer now accepts the exact string unlimited for restic options whose descriptions contain use 'unlimited'. A test checks the validation pattern for keep-last and the absence of a pattern for max-unused.
Changes
Retention option values
Layer / File(s)
Summary
Customize unlimited values and verify properties config/info_customizer.go, config/info_customizer_test.go
The customizer enables string values with the exact pattern ^unlimited$ when an option description contains use 'unlimited'. Tests check keep-last and confirm that max-unused has no validation pattern.
The change lets the schema accept "unlimited" for restic keep-* options alongside integers. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: restic keep-* options in the JSON schema now accept 'unlimited'. It matches the objectives and the raw summary, which describes a property customizer for options whose…
Description check
The description states the problem (restic's keep-* help text says 'use unlimited', but the schema types them as integer only), the fix (a property customizer next to the verbose one), the schema befo…
Linked Issues check
[#449] Requires that the v1 and v2 JSON schemas accept "unlimited" for the --keep-* options in the retention and forget sections, alongside integers. At head 0c9b71d, config/info_customizer.go adds a …
Out of Scope Changes check
The change set has two parts: a customizer in config/info_customizer.go (+9 lines) and TestResticKeepUnlimitedProperty in config/info_customizer_test.go (+19 lines). Both directly implement the #449 o…
Full details: Title check
Explanation
The title names the main change: restic keep-* options in the JSON schema now accept 'unlimited'. It matches the objectives and the raw summary, which describes a property customizer for options whose descriptions mention 'unlimited'. The title uses the 'fix:' prefix and is specific.
Full details: Description check
Explanation
The description states the problem (restic's keep-* help text says 'use unlimited', but the schema types them as integer only), the fix (a property customizer next to the verbose one), the schema before and after, the test, and an end-to-end validation. It relates directly to the changeset.
Full details: Linked Issues check
Explanation
[#449] Requires that the v1 and v2 JSON schemas accept "unlimited" for the --keep-* options in the retention and forget sections, alongside integers. At head 0c9b71d, config/info_customizer.go adds a customizer. When an option description contains "use 'unlimited'", the customizer sets info.mayString = true and info.pattern = ^unlimited$. The keep-* options use this description, so their schema type becomes integer or string, and a string must match ^unlimited$. The type is an integer-or-string union, so the integer and string branches are disjoint and a oneOf is valid. The issue proposes enum ["unlimited"]. The pattern form accepts the same value and is an accepted alternative to the proposed enum. The customizer runs on the shared property information used by schema generation. The author reports an end-to-end check of the v2 schema (master rejects keep-last: "unlimited"; this branch accepts it). The v1 schema is not checked end to end in the PR description. The shared code path covers v1 by design, but this was not verified directly. The unit test TestResticKeepUnlimitedProperty covers the customizer behaviour, including an option without 'unlimited' left unchanged. No non-coding requirement applies.
Full details: Out of Scope Changes check
Explanation
The change set has two parts: a customizer in config/info_customizer.go (+9 lines) and TestResticKeepUnlimitedProperty in config/info_customizer_test.go (+19 lines). Both directly implement the #449 objective. The customizer applies only to options whose description contains "use 'unlimited'", so it does not alter other schema properties. The test covers both the affected option and an unaffected option. No unrelated change was found in the reviewed diff of config/info_customizer.go.
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6a2476c3-c85d-480c-a5b9-4f74a63168c8
Commits
Reviewing files that changed from the base of the PR and between cce8511 and 0c9b71d.
Files selected for processing: 2
config/info_customizer.go
config/info_customizer_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.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.42%. Comparing base (cce8511) to head (0c9b71d). ⚠️ Report is 2 commits behind head on master.
This looks good, but actually someone else did open a PR for the same fix a couple of weeks ago, and actually I slightly prefer the other one, sorry 😉 #683
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
duplicateThis issue or pull request already exists
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #449
restic's help for
--keep-last,--keep-hourly,--keep-daily,--keep-weekly,--keep-monthlyand--keep-yearlysays "use 'unlimited' to keep all ...". The default for each of these options is0, sonewResticPropertyInfotypes them as integer only. Both the v1 and v2 schemas then rejectkeep-last: unlimitedin theforgetandretentionsections.This adds a property customizer, next to the existing one for
verbose. A restic option whose description offers'unlimited'may also be a string, and the string must match^unlimited$. The flags are passed to restic unchanged, so only the schema changes.keep-lastin the v2 schema:This is the
oneOfproposed in the issue.Checks:
TestResticKeepUnlimitedPropertyinconfig/info_customizer_test.go: before the customizer runs, the option is numeric only; after it runs, it is numeric or string with the pattern. An option without'unlimited'in its description is left alone.resticprofile generate --json-schema v2on master and on this branch, then validated{"forget": {"keep-last": "unlimited", "keep-daily": 7}}with Pythonjsonschema(Draft 2020-12). Master reports'unlimited' is not of type 'integer', and this branch reports it valid.go test -short ./config/...andgo vet ./config/pass.