Skip to content

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

Open
ericbyz wants to merge 1 commit into
creativeprojects:masterfrom
ericbyz:fix/keep-unlimited-jsonschema
Open

ericbyz wants to merge 1 commit into
creativeprojects:masterfrom
ericbyz:fix/keep-unlimited-jsonschema

Conversation

@ericbyz

@ericbyz ericbyz commented Oct 9, 2026

Copy link
Copy Markdown

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

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.

This branch has not been deployed

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

Labels

None yet

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

1 participant