Skip to content

fix(config): reject a plan type outside paygo | token | coding - #459

Merged
argszero merged 1 commit into
mainfrom
fix/plan-type-validation
Dec 5, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/plan-type-validation

Conversation

@argszero

@argszero argszero commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

validate() checks that a plan's protocol is one of three values, but never looked at type, which is the same kind of closed set. A config with type = "payg" parsed, validated and started, and the key-listing form then advertised the plan as a subscription: showPlanHint() in ui/js/app.js tests only for "paygo" and renders every other value as share.plan.sub ("Subscription Plan"). A pay-as-you-go key was therefore shown as a subscription, with no error, warning or log line anywhere.

This adds the missing match to validate(), beside the existing protocol check, so a mistyped type is rejected at load with a message that names the plan and the allowed values.

Changes

  • src/config.rs: validate() now rejects a plan type outside paygo | token | coding, in the same shape as the protocol check a few lines below it. The function's doc comment lists the new rule and records why it exists (the frontend only recognises the three values, so anything else is silently rendered as a subscription).
  • src/config.rs: new test validate_rejects_illegal_plan_type, which asserts the error names both the rule and the offending plan id.

Tests

  • cargo test — 618 passed, 0 failed (617 before this change)
  • cargo fmt --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • The new test fails without the fix: on the unmodified tree it panics on unwrap_err() over Ok, i.e. validate() accepted type = "payg". It fails on that assertion, not on a missing symbol.

Behaviour change

A deployment whose config.toml carries a plan type outside the three documented values will now refuse to start, naming the plan and the allowed values, instead of starting and mislabelling the plan. Nothing in this repository is affected: all 16 plans in config/config.example.toml use the documented values, and catalog_gate already asserts that file passes validate().

I chose the reject-at-load direction because it is this function's existing shape for a closed set (the protocol check above it) and because the alternative — accepting the value and only fixing the label — leaves the config stating something the platform does not mean. If you would rather tolerate unknown values for forward compatibility, say so and I will turn this into a normalisation instead.

Not in this change

Plan.interactive_only is declared in the config (with the note "interactive coding tools only, automated batch calls prohibited (compliance)") and is passed through to clients by GET /api/plans, but nothing reads it: no reference in ui/js, no enforcement anywhere in the gateway. Either it is a marker meant for human readers, or it is a restriction that was never implemented. I left it alone because which one it is is your call, and it is now tracked as #460, which this pull request deliberately does not close — an issue asking a question should not be closed by a change that only fixes its sibling. It seemed worth naming here too rather than leaving it to be rediscovered.

validate() checked the protocol enum but never the plan type. A config with
type = "payg" parsed, validated and started, and the key-listing form then
reported the plan as a subscription: showPlanHint() in ui/js/app.js tests only
for "paygo" and renders every other value as share.plan.sub. A pay-as-you-go
key was advertised as a subscription, with no error, warning or log line.

Reject it at load, in the same shape as the protocol check it sits beside, so
the message names the plan and the allowed values. No plan in
config/config.example.toml is affected; all 16 use the documented values.
@argszero
argszero merged commit a6f5f56 into main Dec 5, 2026
2 checks passed
@argszero
argszero deleted the fix/plan-type-validation branch December 5, 2026 21:58
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.

1 participant