You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perOpErrorTypeName's hardcoded switch and errwrap.OperationWrappers'
wrapper-count map are coupled by an unstated invariant: a group has a
per-op aggregator type iff its catalog entry declares 2+ wrappers. Today
both sides match, but nothing checks them, so a future catalog edit can
desync the two without any signal -- the dispatch keeps referencing a
per-op type that's no longer reachable, or worse, emits an empty type
name when a 2+-wrapper group lacks a switch arm.
Add a coupling test that asserts both directions:
- every group naming a per-op aggregator type has 2+ wrappers in
OperationWrappers
- every catalog entry with 2+ wrappers has a non-empty per-op
aggregator type
Iterates the catalog directly rather than a duplicate list of switch
arms, so a new switch arm or catalog entry is exercised automatically.
Failure messages are actionable: they name the offending group, the
current state, and the remediation (add wrappers, remove switch arm,
or add a hand-written aggregator).
Ref: opensearch-project#844 (review round 3, F7)
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
24
24
- Enhanced cluster readiness checking for improved test reliability: `testutil.NewClient()` now includes readiness validation (health + cluster state + nodes info)
25
25
- Add `Status` field (`json.RawMessage`) to `TasksGetResp`, `TasksListTask`, and `TaskCancelInfo` for polymorphic task status data; add typed status structs matching the OpenSearch API specification: `BulkByScrollTaskStatus`, `ReplicationTaskStatus`, `ResyncTaskStatus`, `PersistentTaskStatus`; add `Parse*` helpers and `BulkByScrollTaskStatusOrException` for sliced task status ([#788](https://github.com/opensearch-project/opensearch-go/issues/788))
26
26
- Test parallelization support via TEST_PARALLEL environment variable (default: CPU cores - 1, minimum 1)
27
+
- Add `cmd/osgen/emit.TestPerOpErrorTypeName_CatalogConsistency` to pin the catalog <-> switch coupling between `emit.PerOpErrorTypeName` and `errwrap.OperationWrappers`. Asserts three directions: every group naming a per-op aggregator type has 2+ wrappers in the catalog, every catalog entry with 2+ wrappers names a per-op aggregator type, and every group named by the switch is present in the catalog. Does not pin the runtime `emittableWrappers`/`resolveErrorWrappers` paths; today those sets coincide for the only 2+-wrapper groups (`msearch` / `msearch_template`) ([#857](https://github.com/opensearch-project/opensearch-go/pull/857))
27
28
- opensearchapi/testutil package with test suite, client helpers, and JSON comparison utilities
28
29
- Add typed path builders in `internal/path/` generated from the OpenAPI spec via `cmd/osgen` for compile-time URL construction safety ([#617](https://github.com/opensearch-project/opensearch-go/issues/617), [#650](https://github.com/opensearch-project/opensearch-go/issues/650))
29
30
-`sync.Pool`-backed `[]byte` buffers eliminate per-request allocation churn; buffers over 4 KiB are discarded to bound pool growth
"group %q declares %d wrappers %v in OperationWrappers but PerOpErrorTypeName returns empty; add a switch arm and a hand-written %q-style aggregator type",
369
+
group, len(wrappers), wrappers, group)
370
+
})
371
+
}
372
+
373
+
// (3) Switch-arm catalog presence: every group named by the
374
+
// per-op switch must appear in OperationWrappers. A switch arm
375
+
// for a group missing from the catalog is dead code: neither
376
+
// loop above iterates it, so without this check it could
"perOpErrorTypeName has a switch arm for group %q but the group is absent from errwrap.OperationWrappers; remove the arm or restore the catalog entry",
0 commit comments