Skip to content

Commit f36e8be

Browse files
authored
Fix field path in error message for HTTPRoute path validation (#587)
Bug was introduced in 52fab05
1 parent 1711524 commit f36e8be

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

internal/state/graph/httproute.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@ func validatePathMatch(
524524
}
525525

526526
if *path.Type != v1beta1.PathMatchPathPrefix {
527-
valErr := field.NotSupported(fieldPath, *path.Type, []string{string(v1beta1.PathMatchPathPrefix)})
527+
valErr := field.NotSupported(fieldPath.Child("type"), *path.Type, []string{string(v1beta1.PathMatchPathPrefix)})
528528
allErrs = append(allErrs, valErr)
529529
}
530530

531531
if err := validator.ValidatePathInPrefixMatch(*path.Value); err != nil {
532-
valErr := field.Invalid(fieldPath, *path.Value, err.Error())
532+
valErr := field.Invalid(fieldPath.Child("value"), *path.Value, err.Error())
533533
allErrs = append(allErrs, valErr)
534534
}
535535

internal/state/graph/httproute_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ func TestBuildRoute(t *testing.T) {
520520
},
521521
Conditions: []conditions.Condition{
522522
conditions.NewRouteUnsupportedValue(
523-
`All rules are invalid: spec.rules[0].matches[0].path: Invalid value: "/invalid": invalid path`,
523+
`All rules are invalid: spec.rules[0].matches[0].path.value: Invalid value: "/invalid": invalid path`,
524524
),
525525
},
526526
Rules: []Rule{
@@ -581,7 +581,7 @@ func TestBuildRoute(t *testing.T) {
581581
Conditions: []conditions.Condition{
582582
conditions.NewTODO(
583583
`Some rules are invalid: ` +
584-
`[spec.rules[0].matches[0].path: Invalid value: "/invalid": invalid path, ` +
584+
`[spec.rules[0].matches[0].path.value: Invalid value: "/invalid": invalid path, ` +
585585
`spec.rules[1].filters[0].requestRedirect.hostname: Invalid value: ` +
586586
`"invalid.example.com": invalid hostname]`,
587587
),

0 commit comments

Comments
 (0)