-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[datadog_synthetics_test] Do not send field
if empty
#2533
[datadog_synthetics_test] Do not send field
if empty
#2533
Conversation
transfer_encoding: [] | ||
trailer: {} | ||
host: api.datadoghq.com | ||
remote_addr: "" | ||
request_uri: "" | ||
body: | | ||
{"config":{"assertions":[],"configVariables":[{"id":"43883ccf-136d-4a4c-b6c3-8d2e2e0520f7","name":"VARIABLE_NAME","type":"global"}],"steps":[{"allowFailure":true,"assertions":[{"operator":"is","target":200,"type":"statusCode"},{"operator":"validatesJSONSchema","target":{"jsonSchema":"{\"type\": \"object\", \"properties\":{\"slideshow\":{\"type\":\"object\"}}}","metaSchema":"draft-07"},"type":"body"}],"extractedValues":[{"field":"content-length","name":"VAR_EXTRACT","parser":{"type":"regex","value":".*"},"secure":true,"type":"http_header"}],"isCritical":false,"name":"First api step","request":{"allow_insecure":true,"basicAuth":{"accessKey":"sigv4-access-key","region":"sigv4-region","secretKey":"sigv4-secret-key","serviceName":"sigv4-service-name","sessionToken":"sigv4-session-token","type":"sigv4"},"body":"this is a body","certificate":{"cert":{"content":"content-certificate","filename":"Provided in Terraform config"},"key":{"content":"content-key","filename":"key"}},"follow_redirects":true,"headers":{"Accept":"application/json","X-Datadog-Trace-ID":"123456789"},"httpVersion":"http2","method":"POST","noSavingResponseBody":true,"persistCookies":false,"proxy":{"headers":{"Accept":"application/json","X-Datadog-Trace-ID":"123456789"},"url":"https://proxy.url"},"query":{"foo":"bar"},"timeout":30,"url":"https://www.datadoghq.com"},"retry":{"count":5,"interval":1000},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":200,"type":"statusCode"}],"extractedValues":[],"isCritical":false,"name":"Second api step","request":{"allow_insecure":true,"basicAuth":{"accessTokenUrl":"https://token.datadoghq.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","scope":"scope","tokenApiAuthentication":"header","type":"oauth-client"},"follow_redirects":true,"httpVersion":"any","method":"GET","noSavingResponseBody":false,"persistCookies":false,"timeout":30,"url":"https://docs.datadoghq.com"},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":200,"type":"statusCode"}],"extractedValues":[],"isCritical":false,"name":"Third api step","request":{"allow_insecure":true,"basicAuth":{"accessTokenUrl":"https://token.datadoghq.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","password":"password","resource":"resource","scope":"scope","tokenApiAuthentication":"body","type":"oauth-rop","username":"username"},"follow_redirects":true,"httpVersion":"any","method":"GET","noSavingResponseBody":false,"persistCookies":false,"timeout":30,"url":"https://docs.datadoghq.com"},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":200,"type":"statusCode"}],"extractedValues":[],"isCritical":false,"name":"Fourth api step","request":{"allow_insecure":true,"basicAuth":{"password":"password","type":"digest","username":"username"},"follow_redirects":true,"httpVersion":"any","method":"GET","noSavingResponseBody":false,"persistCookies":false,"timeout":30,"url":"https://docs.datadoghq.com"},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":1,"type":"grpcHealthcheckStatus"}],"extractedValues":[],"isCritical":false,"name":"gRPC health check step","request":{"allow_insecure":false,"callType":"healthcheck","host":"https://docs.datadoghq.com","message":"","metadata":{"foo":"bar"},"method":"","port":443,"service":"greeter.Greeter","timeout":0},"subtype":"grpc"},{"allowFailure":false,"assertions":[{"operator":"validatesJSONPath","target":{"elementsOperator":"firstElementMatches","jsonPath":"$.message","operator":"is","targetValue":"Hello, John!"},"type":"grpcProto"}],"extractedValues":[],"isCritical":false,"name":"gRPC behavior check step","request":{"allow_insecure":false,"callType":"unary","compressedProtoFile":"eJwqzs9NVSgoyi/JV0jLzEkFBAAA//8u0wXJ","host":"https://docs.datadoghq.com","message":"{\"name\": \"John\"}","metadata":{"foo":"bar"},"method":"SayHello","port":443,"service":"greeter.Greeter","timeout":0},"subtype":"grpc"},{"name":"Wait step","subtype":"wait","value":5}]},"locations":["aws:eu-central-1"],"message":"Notify @datadog.user","name":"tf-TestAccDatadogSyntheticsTestMultistepApi_Basic-local-1722543180","options":{"httpVersion":"any","min_location_failed":1,"tick_every":900},"status":"paused","subtype":"multi","tags":["multistep"],"type":"api"} | ||
{"config":{"assertions":[],"configVariables":[{"id":"e0da7993-a9f0-45de-af3f-10e726239bcd","name":"VARIABLE_NAME","type":"global"}],"steps":[{"allowFailure":true,"assertions":[{"operator":"is","target":200,"type":"statusCode"},{"operator":"validatesJSONSchema","target":{"jsonSchema":"{\"type\": \"object\", \"properties\":{\"slideshow\":{\"type\":\"object\"}}}","metaSchema":"draft-07"},"type":"body"}],"extractedValues":[{"name":"VAR_EXTRACT_BODY","parser":{"type":"json_path","value":"$.id"},"secure":false,"type":"http_body"},{"field":"content-length","name":"VAR_EXTRACT_HEADER","parser":{"type":"regex","value":".*"},"secure":true,"type":"http_header"}],"isCritical":false,"name":"First api step","request":{"allow_insecure":true,"basicAuth":{"accessKey":"sigv4-access-key","region":"sigv4-region","secretKey":"sigv4-secret-key","serviceName":"sigv4-service-name","sessionToken":"sigv4-session-token","type":"sigv4"},"body":"this is a body","certificate":{"cert":{"content":"content-certificate","filename":"Provided in Terraform config"},"key":{"content":"content-key","filename":"key"}},"follow_redirects":true,"headers":{"Accept":"application/json","X-Datadog-Trace-ID":"123456789"},"httpVersion":"http2","method":"POST","noSavingResponseBody":true,"persistCookies":false,"proxy":{"headers":{"Accept":"application/json","X-Datadog-Trace-ID":"123456789"},"url":"https://proxy.url"},"query":{"foo":"bar"},"timeout":30,"url":"https://www.datadoghq.com"},"retry":{"count":5,"interval":1000},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":200,"type":"statusCode"}],"extractedValues":[],"isCritical":false,"name":"Second api step","request":{"allow_insecure":true,"basicAuth":{"accessTokenUrl":"https://token.datadoghq.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","scope":"scope","tokenApiAuthentication":"header","type":"oauth-client"},"follow_redirects":true,"httpVersion":"any","method":"GET","noSavingResponseBody":false,"persistCookies":false,"timeout":30,"url":"https://docs.datadoghq.com"},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":200,"type":"statusCode"}],"extractedValues":[],"isCritical":false,"name":"Third api step","request":{"allow_insecure":true,"basicAuth":{"accessTokenUrl":"https://token.datadoghq.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","password":"password","resource":"resource","scope":"scope","tokenApiAuthentication":"body","type":"oauth-rop","username":"username"},"follow_redirects":true,"httpVersion":"any","method":"GET","noSavingResponseBody":false,"persistCookies":false,"timeout":30,"url":"https://docs.datadoghq.com"},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":200,"type":"statusCode"}],"extractedValues":[],"isCritical":false,"name":"Fourth api step","request":{"allow_insecure":true,"basicAuth":{"password":"password","type":"digest","username":"username"},"follow_redirects":true,"httpVersion":"any","method":"GET","noSavingResponseBody":false,"persistCookies":false,"timeout":30,"url":"https://docs.datadoghq.com"},"subtype":"http"},{"allowFailure":false,"assertions":[{"operator":"is","target":1,"type":"grpcHealthcheckStatus"}],"extractedValues":[],"isCritical":false,"name":"gRPC health check step","request":{"allow_insecure":false,"callType":"healthcheck","host":"https://docs.datadoghq.com","message":"","metadata":{"foo":"bar"},"method":"","port":443,"service":"greeter.Greeter","timeout":0},"subtype":"grpc"},{"allowFailure":false,"assertions":[{"operator":"validatesJSONPath","target":{"elementsOperator":"firstElementMatches","jsonPath":"$.message","operator":"is","targetValue":"Hello, John!"},"type":"grpcProto"}],"extractedValues":[],"isCritical":false,"name":"gRPC behavior check step","request":{"allow_insecure":false,"callType":"unary","compressedProtoFile":"eJwqzs9NVSgoyi/JV0jLzEkFBAAA//8u0wXJ","host":"https://docs.datadoghq.com","message":"{\"name\": \"John\"}","metadata":{"foo":"bar"},"method":"SayHello","port":443,"service":"greeter.Greeter","timeout":0},"subtype":"grpc"},{"name":"Wait step","subtype":"wait","value":5}]},"locations":["aws:eu-central-1"],"message":"Notify @datadog.user","name":"tf-TestAccDatadogSyntheticsTestMultistepApi_Basic-local-1723819609","options":{"httpVersion":"any","min_location_failed":1,"tick_every":900},"status":"paused","subtype":"multi","tags":["multistep"],"type":"api"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the request body generated by Terraform, notice that VAR_EXTRACT_BODY
doesn't have a field
property:
{
...
"extractedValues": [
{
"name": "VAR_EXTRACT_BODY",
"parser": {"type": "json_path", "value": "$.id"},
"secure": false,
"type": "http_body"
},
{
"field": "content-length",
"name": "VAR_EXTRACT_HEADER",
"parser": {"type": "regex", "value": ".*"},
"secure": true,
"type": "http_header"
}
]
}
field
if emptyfield
if empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Closes #2531
This PR is a follow up of a fix in our backend, where part of a request wasn't fully validated, resulting in silent errors.
Now that this was fixed in the backend, it revealed that Terraform was always sending a
field
property, even when not allowed.