fix(channels): fall back to empty defaults on unmarshal errors (#1108) #2347
Reference in New Issue
Block a user
Delete Branch "fix/channels-unmarshal-fallback-invalid-json"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Invalid JSON in channel_config or allowed_users previously left the corresponding variables nil, causing downstream nil-pointer risks in List and Webhook handlers.
Changes
Verification
SOP Checklist
Comprehensive testing performed
Added
TestChannelHandler_List_InvalidJSON_FallsBackcovering invalid configJSON and allowedJSON.Local-postgres E2E run
N/A — handler unit tests with sqlmock suffice.
Staging-smoke verified or pending
N/A — no runtime behavior change for valid data.
Root-cause not symptom
Fixes nil-pointer risk from invalid JSON rather than masking the error.
Five-Axis review walked
No backwards-compat shim / dead code added
No shims.
Memory/saved-feedback consulted
N/A — standard defensive programming pattern.
Related
5-axis review on current head
90852601cc.Correctness: the channel List and Webhook paths now handle invalid stored JSON by logging and falling back to concrete empty defaults (map for config, slice for allowed_users). That avoids nil/partial decoded values reaching downstream code while keeping corrupted rows from crashing the request path; Webhook correctly falls through to no_channel with empty config. Tests cover both List and Webhook invalid-JSON fallback behavior.
Robustness/security: this is fail-safe for corrupted DB rows; it does not widen access because invalid allowed_users becomes an empty list, and invalid config cannot match a channel target. No new secret handling or network behavior. Performance impact is negligible. Readability is clear.
Scope note: the PR also includes docs-only backend-contract status text and EIC diagnostic JSON logging already seen in adjacent low-risk changes; both are non-product behavior changes. Required contexts are green and mergeable=true.
Official APPROVED on current head. Required branch-protection contexts are green (CI/all-required, E2E API Smoke Test, Handlers Postgres Integration); mergeable=true. Governance reds are non-required pre-#2331. Diff is the channel JSON fallback fix, low-risk and fail-closed.