We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Inline
"Regular" config struct attributes are validated at config load. Several Inline attributes, however, are not validated at all.
E.g. proxy:
proxy
func (p Proxy) Inline() interface{} { type Inline struct { meta.RequestHeadersAttributes meta.ResponseHeadersAttributes meta.FormParamsAttributes meta.QueryParamsAttributes Backend *Backend `hcl:"backend,block" ...` ExpectedStatus []int `hcl:"expected_status,optional" ...` URL string `hcl:"url,optional" ...` Websockets *Websockets `hcl:"websockets,block" ...` } return &Inline{} }
proxy { url = 42 }
URL is validated at runtime by producer.NewURLFromAttribute(). OK
URL
producer.NewURLFromAttribute()
proxy { expected_status = 200 }
ExpectedStatus with an invalid type (e.g. int instead of []int) is quietly ignored: handler/proxy.go
ExpectedStatus
int
[]int
expStatusVal, err := eval.ValueFromBodyAttribute(hclCtx, p.context, "expected_status") if err != nil { return nil, err } outCtx = context.WithValue(outCtx, request.EndpointExpectedStatus, seetie.ValueToIntSlice(expStatusVal))
with
func ValueToIntSlice(src cty.Value) []int64 { var n []int64 if !src.IsKnown() || src.IsNull() || !src.CanIterateElements() { return n }
returning an empty slice, then ignored in handler/producer/result.go because len() of the empty slice is not > 0
len()
> 0
if expStatus, ok := req.Context().Value(request.EndpointExpectedStatus).([]int64); beresp != nil && ok && len(expStatus) > 0 { ...
proxy { set_request_headers = 42 }
even panics.
As it seems, the Inline is only used to create another BodySchema to find unsupported attributes/blocks in (config/configload/schema.go)
BodySchema
func completeSchemaComponents(body hcl.Body, schema *hcl.BodySchema, blocks hcl.Blocks, errors hcl.Diagnostics) (hcl.Blocks, hcl.Diagnostics) { content, diags := body.Content(schema)
How can we use the type information from the Inline structs returned by .Inline() to validate attribute values?
.Inline()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
"Regular" config struct attributes are validated at config load. Several
Inline
attributes, however, are not validated at all.E.g.
proxy
:URL
is validated at runtime byproducer.NewURLFromAttribute()
. OKExpectedStatus
with an invalid type (e.g.int
instead of[]int
) is quietly ignored:handler/proxy.go
with
returning an empty slice, then ignored in handler/producer/result.go because
len()
of the empty slice is not> 0
even panics.
As it seems, the
Inline
is only used to create anotherBodySchema
to find unsupported attributes/blocks in (config/configload/schema.go)How can we use the type information from the
Inline
structs returned by.Inline()
to validate attribute values?The text was updated successfully, but these errors were encountered: