fix(alertgroups): add expression validator to detect new lines on expressions (#807)

This commit is contained in:
Mauritz Uphoff 2025-05-07 11:54:54 +02:00 committed by GitHub
parent 9cd402e09f
commit f4498e85f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 111 additions and 1 deletions

View file

@ -207,6 +207,10 @@ func (a *alertGroupResource) Schema(_ context.Context, _ resource.SchemaRequest,
Required: true,
Validators: []validator.String{
stringvalidator.LengthBetween(1, 600),
// The API currently accepts expressions with trailing newlines but does not return them,
// leading to inconsistent Terraform results. This issue has been reported to the Obs team.
// Until it is resolved, we proactively notify users if their input contains a trailing newline.
validate.ValidNoTrailingNewline(),
},
},
"for": schema.StringAttribute{

View file

@ -207,6 +207,10 @@ func (l *logAlertGroupResource) Schema(_ context.Context, _ resource.SchemaReque
Required: true,
Validators: []validator.String{
stringvalidator.LengthBetween(1, 600),
// The API currently accepts expressions with trailing newlines but does not return them,
// leading to inconsistent Terraform results. This issue has been reported to the Obs team.
// Until it is resolved, we proactively notify users if their input contains a trailing newline.
validate.ValidNoTrailingNewline(),
},
},
"for": schema.StringAttribute{

View file

@ -997,7 +997,7 @@ func toNodepoolsPayload(ctx context.Context, m *Model, availableMachineVersions
if v.IsNull() || v.IsUnknown() {
continue
}
s, err := conversion.ToString(context.TODO(), v)
s, err := conversion.ToString(ctx, v)
if err != nil {
continue
}