Skip to content

validate_params#412

Open
Minin1991 wants to merge 1 commit into
haproxytech:masterfrom
Minin1991:v3.4.0-custom
Open

validate_params#412
Minin1991 wants to merge 1 commit into
haproxytech:masterfrom
Minin1991:v3.4.0-custom

Conversation

@Minin1991

Copy link
Copy Markdown

Hello!
Previously, JSON request bodies containing unknown fields could be accepted by the Data Plane API and silently decoded into client-native models with unsupported fields dropped.

This made it possible for users or automation pipelines to believe that a submitted configuration parameter was applied, while the field was actually ignored during decoding.

Add a strict pre-decode validation step in the JSON consumer. The request body is first decoded into a generic JSON structure and checked against the target Go model using reflection. If an unknown field is found, the API now returns a parsing error instead of silently dropping the field.

The check supports nested structs, embedded model structs, maps such as backend servers, and arrays. Plain text raw configuration endpoints are excluded from this validation.

This helps GitOps/CI pipelines fail early when a request contains misspelled or unsupported configuration parameters.

Please confirm your decision and add this functionality to the build. #405

Problem details. When requesting new edits, there will be no errors with such a request:
cat >/tmp/resolver_bad.json <<'EOF'
{
"name": "_dns_bad2",
"accepted_payload_size": 8192,
"parse-resolv-conf": false,
"resolve_retries": 3,
"timeout_retry": 1000,
"bad_unknown_param": "should_be_detected"
}
EOF

curl -i -u "$DP_USER:$DP_PASS"
-X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
--data-binary @/tmp/resolver_bad.json
"$DP_URL/services/haproxy/configuration/resolvers?transaction_id=$TXID"

And in case of using pull req #405 :
HTTP/1.1 400 Bad Request
unknown field "bad_unknown_param"

Thanks.

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