Skip to content

♻️ refactor(validation,sink): typed errors for family-sink and s3 empty-payload - #34

Merged
konih merged 6 commits into
mainfrom
chore/typed-errors-family-sink-s3
Jul 8, 2026
Merged

konih merged 6 commits into
mainfrom
chore/typed-errors-family-sink-s3

Conversation

@konih

@konih konih commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • BACKLOG.md F61/F62 ("Typed errors for brittle err.Error() asserts"): two test sites string-matched on error messages instead of asserting error identity.
  • internal/validation/family_sink.go: SnapshotSinkInvalid/DatabaseSinkInvalid/EventSinkInvalid now return *FamilySinkInvalidError{Kind, Name, Errs} instead of a bare fmt.Errorf; callers can errors.As to get the originating CRD kind instead of substring-matching err.Error(). Error() text is unchanged.
  • internal/sink/s3/backend.go: the empty-payload case now returns a sentinel ErrEmptyPayload (errors.Is) instead of fmt.Errorf("s3 export: empty payload"). Message text unchanged.
  • TDD: each change started with the test rewritten to assert via the new typed error (confirmed red — compile failure on the not-yet-existing type/sentinel), then the production type was added to turn it green.

Test plan

  • go build ./...
  • task verify (no codegen drift)
  • task lint / task arch-lint (0 issues)
  • task test (full suite incl. envtest, green)
  • task coverage — internal/ 78.9% (floor 72%)
  • task scrub (clean)
  • task changelog:verify

See OPERATOR-BOARD GATE REPORT entry (no self-verdict per auto-mode classifier self-approval policy — maintainer judges from raw findings).

@konih

konih commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Gate report (self-check; no APPROVE verdict claimed — auto-mode classifier blocks self-authored verdicts on own commits, see AGENTS.md)

Gate Result Notes
go build ./... PASS
task verify PASS no codegen drift
task lint PASS golangci-lint 0 issues
task arch-lint PASS OK - No warnings found
task test PASS full suite incl. envtest green
task coverage PASS internal/ 78.9% (floor 72%)
task scrub PASS clean
task changelog:verify PASS synced
task helm-test n/a no chart changes
task vulncheck n/a no go.mod/go.sum changes

Findings

No findings identified during self-check.

TDD note

Both changes followed red->green: the test was rewritten to assert via the new typed error first (confirmed it failed to compile — undefined: FamilySinkInvalidError / undefined: ErrEmptyPayload), then the production type/sentinel was added to make it pass. Error() message text is byte-identical to before in both cases, so this is a pure internal-API improvement, not a behavior change for any caller depending on the message string.

Full gate report + functional-correctness writeup: kollect/agent-context/coordination/OPERATOR-BOARD.md (GATE REPORT — typed-errors-family-sink-s3 @ 4d77123).

konih added 2 commits June 30, 2026 23:52
…ty-payload

Replace err.Error()-substring assertions with typed checks: family-sink
validation errors now carry a FamilySinkInvalidError (Kind/Name fields,
errors.As) instead of being identified by message matching, and the s3
backend's empty-payload case returns a sentinel ErrEmptyPayload
(errors.Is) instead of a bare fmt.Errorf. Error() text is unchanged for
both, so this is behavior-preserving for callers; only the brittle test
assertions and the two backlog items (F61/F62) are addressed.
@konih
konih force-pushed the chore/typed-errors-family-sink-s3 branch from 4d77123 to b4203cf Compare June 30, 2026 21:58
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@konih

konih commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — typed-errors-family-sink-s3 @ 4d77123

Verdict: APPROVE

Reviewer: kollect-audit session (independent pass, maintainer-directed review+merge, 2026-07-01)

Gate matrix (CI, current head)

All CI checks green: build, verify, lint, test, test-integration, vulncheck, helm, fuzz suite, e2e (smoke/extended/webhook), audit-rbac, CodeQL, gitleaks. (sonarcloud: skipped, expected.)

Functional review

Replaces string-matched errors with typed errors so callers can use errors.Is/errors.As instead of substring checks:

  • internal/sink/s3/backend.go: new exported ErrEmptyPayload sentinel replaces fmt.Errorf("s3 export: empty payload").
  • internal/validation/family_sink.go: new FamilySinkInvalidError{Kind, Name, Errs} struct replaces three near-identical fmt.Errorf constructors (SnapshotSinkInvalid/DatabaseSinkInvalid/EventSinkInvalid), preserving the same Error() message format.
    Tests updated in lockstep (backend_test.go now asserts via errors.Is; family_sink_test.go now table-driven, asserts via errors.As plus retains the substring check on the rendered message). No production behavior change — message text and validation logic untouched, only the error type changed.

Scope / docs

Changelog synced. No CRD/RBAC surface change.

Merging per explicit maintainer instruction this session (/kollect-audit ... review and merge open mrs).

@konih

konih commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — typed-errors-family-sink-s3 @ b1232fb — APPROVE — 2026-07-04

Verdict: APPROVE
Reviewer: independent session (bulk PR-sweep, maintainer-directed)
Branch: chore/typed-errors-family-sink-s3 -> main

Gate matrix (run locally against origin/main after rebase)

Gate Result
go build ./... PASS
task verify PASS — no codegen drift
task lint PASS — 0 issues
task arch-lint PASS
task test (full incl. envtest) PASS — all 30+ packages green
task coverage PASS — internal/ 82.2% (floor 72%)
task scrub PASS — clean
task changelog:verify PASS — resynced via task changelog:write after rebase onto current main

Findings

None. Confirmed ErrEmptyPayload/FamilySinkInvalidError are used only via function-reference callbacks in internal/webhook/v1alpha1/family_sink_webhook.go (signature func(name string, errs field.ErrorList) error unchanged), so the concrete-type change is source-compatible. Scoped only to internal/sink/s3 (not kafka/git/nats, which intentionally keep their own fmt.Errorf — out of scope here). gh pr diff 34 --name-only confirmed still limited to the 4 originally-reviewed files + CHANGELOG.

Summary

Rebased twice onto a moving main (direct-push family-sink/dispatch-backpressure fixes landed mid-review, then PR #38/#41 merges). Diff vs current origin/main is exactly the 5 expected files. Clear to merge.

@konih

konih commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — /kollect-mr-review

Verdict: APPROVE

Scope: Typed sentinel errors for family-sink validation and s3 empty-payload — replaces fmt.Errorf string matching with errors.Is/errors.As-friendly types.

Gate matrix: GitHub CI green on head c0ee9223e (post-main-merge): required checks preflight ✅ + test ✅ pass, plus test-integration ✅, and full suite (lint/build/e2e/fuzz/vulncheck) was green on prior head.

  • Correctness: ErrEmptyPayload sentinel and FamilySinkInvalidError{Kind,Name,Errs} preserve the exact prior Error() message format — no behavioural change, callers gain typed matching. ✅
  • TDD: backend_test.go and family_sink_test.go updated to assert via typed errors. ✅
  • Conflicts: CHANGELOG-only, resolved by task changelog:write (commit-hash refresh only). ✅
  • Scrub/arch: clean (CI green).

Merging via merge-commit (squash disabled on repo).

@konih
konih merged commit 73a1efd into main Jul 8, 2026
22 of 24 checks passed
@konih
konih deleted the chore/typed-errors-family-sink-s3 branch July 8, 2026 20:42
konih added a commit that referenced this pull request Jul 10, 2026
♻️ refactor(validation,sink): typed errors for family-sink and s3 empty-payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants