Name a nested payload's problems with PayloadError.Within

The notify module names the problems of an action, an object inside its
payload, by the action's place in the payload. The module routes need
the same for a payload sent inside a larger request body, so the naming
becomes a method of PayloadError. What notify reports does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 21:51:10 -06:00
1 parent 2e291817d3
commit cbac0b5f03
3 files changed
+35 -9

No files matched your search

+18
View File
@@ -79,6 +79,24 @@ func TestRegistryRefusals(t *testing.T) {
}
}
// A payload's problems name their field from the place that holds the
// payload, and a problem with the whole payload names that place.
func TestPayloadErrorWithin(t *testing.T) {
err := &modules.PayloadError{Problems: []string{
"body: expected a JSON object, got array",
"done[0]: index 5 is out of range",
`"we ird": unknown field`,
}}
want := []string{
"payload: expected a JSON object, got array",
"payload.done[0]: index 5 is out of range",
`payload."we ird": unknown field`,
}
if got := err.Within("payload"); strings.Join(got, "\n") != strings.Join(want, "\n") {
t.Errorf("Within = %q, want %q", got, want)
}
}
func TestEnvStamp(t *testing.T) {
london, err := time.LoadLocation("Europe/London")
if err != nil {