Validate operation value arity in propose_operations#5
Merged
Conversation
The generic write driver passed each op's comma-joined value straight through to VyManager without checking how many args it contained. A value carrying the wrong number of args (most commonly the subject re-included, e.g. "dum10,10.100.10.10/32" for a 1-arg address op) was only rejected at the device as an opaque HTTP 400 from /configure. - propose_operations now checks the comma-separated arg count against the op's expected post-subject arity and raises a clear error at propose time, naming the expected args and reminding that the subject is supplied via fields. - describe_feature_operations now exposes per-op value_args and value_arg_count (the args the value must supply, subject stripped) and a sharper note, so callers see the exact value shape up front. Bump version to 0.1.2 (also syncs __init__ __version__, which lagged).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The generic write driver passed each op's comma-joined
valuestraight through to VyManager without checking how many args it contained. When a value carried the wrong number of args — most commonly the subject re-included, e.g."dum10,10.100.10.10/32"for a 1-arg address op — nothing caught it locally. It was only rejected at the device as an opaqueHTTP 400from/configure, with the real VyOS error swallowed upstream, making it very hard to diagnose.Changes
propose_operationsnow checks the comma-separated arg count against the op's expected post-subject arity and raises a clear error at propose time — naming the expected args and reminding that the subject is supplied viafields, not the value.describe_feature_operationsnow exposes per-opvalue_argsandvalue_arg_count(the args the value must supply, with the subject stripped) plus a sharper note, so callers see the exact value shape up front instead of inferring it from a subject-mixed arg list.0.1.2(also syncs__init__.__version__, which had lagged at0.1.0).Tests
Adds coverage for: subject-in-value rejection, correct single-value accepted, too-many-args on a non-subject feature, and the enriched
describeoutput/note. Full suite (71 tests),ruff check, andmypyall pass.