fix(channels): fall back to empty defaults on unmarshal errors (#1108) #2347

Merged
claude-ceo-assistant merged 3 commits from fix/channels-unmarshal-fallback-invalid-json into main 2026-06-06 07:55:39 +00:00
Member

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

  • Set config to empty map on unmarshal failure
  • Set allowed_users to empty slice on unmarshal failure
  • Add tests covering invalid JSON in both List and Webhook paths

Verification

  • New unit tests pass
  • Existing channel tests still pass

SOP Checklist

Comprehensive testing performed

Added TestChannelHandler_List_InvalidJSON_FallsBack covering 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

  • Correctness: empty defaults are safe fallbacks; errors are still logged
  • Readability: minimal diff, consistent pattern across both handlers
  • Architecture: aligns with existing decrypt-fallback pattern
  • Security: no new surface; invalid JSON is logged, not exposed
  • Performance: negligible (already on error path)

No backwards-compat shim / dead code added

No shims.

Memory/saved-feedback consulted

N/A — standard defensive programming pattern.

Related

## 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 - Set config to empty map on unmarshal failure - Set allowed_users to empty slice on unmarshal failure - Add tests covering invalid JSON in both List and Webhook paths ## Verification - [x] New unit tests pass - [x] Existing channel tests still pass ## SOP Checklist ### Comprehensive testing performed Added `TestChannelHandler_List_InvalidJSON_FallsBack` covering 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 - Correctness: empty defaults are safe fallbacks; errors are still logged - Readability: minimal diff, consistent pattern across both handlers - Architecture: aligns with existing decrypt-fallback pattern - Security: no new surface; invalid JSON is logged, not exposed - Performance: negligible (already on error path) ### No backwards-compat shim / dead code added No shims. ### Memory/saved-feedback consulted N/A — standard defensive programming pattern. ## Related - Closes #1108
core-be added 3 commits 2026-06-06 06:14:49 +00:00
docs(backends): mark drift risk #6 resolved and update contract-test status
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 4s
CI / Python Lint & Test (pull_request) Successful in 4s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 5s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 4s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Failing after 4s
E2E Chat / detect-changes (pull_request) Successful in 13s
CI / Detect changes (pull_request) Successful in 20s
E2E Chat / E2E Chat (pull_request) Successful in 2s
E2E API Smoke Test / detect-changes (pull_request) Successful in 19s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 20s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 19s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 18s
CI / Canvas (Next.js) (pull_request) Successful in 2s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1s
CI / Canvas Deploy Status (pull_request) Has been skipped
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1s
CI / Platform (Go) (pull_request) Successful in 5s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 4s
CI / all-required (pull_request) Successful in 2s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m0s
sop-checklist / review-refire (pull_request_target) Has been skipped
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4
sop-checklist / na-declarations (pull_request) N/A: (none)
gate-check-v3 / gate-check (pull_request_target) Successful in 9s
sop-checklist / all-items-acked (pull_request_target) Successful in 9s
qa-review / approved (pull_request_target) Refired via /qa-recheck by unknown
qa-review / approved (pull_request_review) Has been skipped
security-review / approved (pull_request_review) Has been skipped
sop-tier-check / tier-check (pull_request_review) Successful in 8s
security-review / approved (pull_request_target) Successful in 7s
sop-tier-check / tier-check (pull_request_target) Successful in 18s
9a965cfcea
Drift risk #6 (nil-client panic) was resolved by fix/provisioner-nil-guards-1813.
Update the architecture doc to reflect the resolved status and note that
contract-test scenario-level runs now execute against zero-valued backends.

Closes internal#1813
fix(e2e): emit full diagnose JSON burst on EIC smoke failure (#767)
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 5s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 1s
CI / Python Lint & Test (pull_request) Successful in 7s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 5s
CI / Detect changes (pull_request) Successful in 12s
E2E Chat / detect-changes (pull_request) Successful in 11s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 9s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 15s
E2E API Smoke Test / detect-changes (pull_request) Successful in 16s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 11s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 7s
security-review / approved (pull_request_target) Failing after 4s
qa-review / approved (pull_request_target) Failing after 4s
CI / Platform (Go) (pull_request) Successful in 4s
CI / Canvas (Next.js) (pull_request) Successful in 5s
E2E Chat / E2E Chat (pull_request) Successful in 3s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1s
gate-check-v3 / gate-check (pull_request_target) Successful in 12s
CI / Canvas Deploy Status (pull_request) Has been skipped
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 2s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 20s
CI / all-required (pull_request) Successful in 2s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 56s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1m24s
E2E Staging SaaS (full lifecycle) / E2E Staging Platform Boot (pull_request) Failing after 2m36s
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (pull_request) Failing after 2m9s
E2E Staging SaaS (full lifecycle) / pr-validate (pull_request) Successful in 28s
qa-review / approved (pull_request_review) Has been skipped
security-review / approved (pull_request_review) Has been skipped
sop-tier-check / tier-check (pull_request_review) Successful in 26s
sop-checklist / review-refire (pull_request_target) Has been skipped
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 4s
sop-tier-check / tier-check (pull_request_target) Successful in 4s
2f53bbac6c
When the EIC terminal diagnose step fails, operators previously only saw
the Python-extracted first-failure + detail strings. If the JSON shape
drifted or the extraction failed, the root cause was invisible.

- Add a diagnostic burst that pretty-prints the full diagnose JSON
- Bracket the burst with grep-friendly markers for CI log parsing
- Closes #767
fix(channels): fall back to empty defaults on unmarshal errors
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
CI / Python Lint & Test (pull_request) Successful in 3s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 9s
Harness Replays / detect-changes (pull_request) Successful in 5s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 5s
E2E Chat / detect-changes (pull_request) Successful in 11s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 12s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 11s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 4s
CI / Detect changes (pull_request) Successful in 16s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 13s
E2E API Smoke Test / detect-changes (pull_request) Successful in 19s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 11s
security-review / approved (pull_request_target) Failing after 9s
gate-check-v3 / gate-check (pull_request_target) Successful in 14s
E2E Chat / E2E Chat (pull_request) Successful in 2s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 3s
qa-review / approved (pull_request_target) Failing after 18s
Harness Replays / Harness Replays (pull_request) Successful in 10s
CI / Canvas (Next.js) (pull_request) Successful in 1s
E2E Staging SaaS (full lifecycle) / E2E Staging Platform Boot (pull_request) Failing after 16s
sop-checklist / review-refire (pull_request_target) Has been skipped
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 5s
E2E Staging SaaS (full lifecycle) / pr-validate (pull_request) Successful in 30s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 23s
CI / Canvas Deploy Status (pull_request) Has been skipped
sop-tier-check / tier-check (pull_request_target) Failing after 20s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m22s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1m14s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1m17s
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (pull_request) Failing after 2m26s
CI / Platform (Go) (pull_request) Successful in 4m8s
CI / all-required (pull_request) Successful in 16s
qa-review / approved (pull_request_review) Has been skipped
security-review / approved (pull_request_review) Has been skipped
sop-tier-check / tier-check (pull_request_review) Successful in 8s
audit-force-merge / audit (pull_request_target) Successful in 4s
90852601cc
Invalid JSON in channel_config or allowed_users previously left the
corresponding variables nil, causing downstream nil-pointer risks.

- Set config to empty map on unmarshal failure\n- Set allowed_users to empty slice on unmarshal failure\n- Add tests covering invalid JSON in both List and Webhook paths\n\nCloses #1108
core-be added the tier:low label 2026-06-06 06:15:13 +00:00
agent-reviewer-cr2 approved these changes 2026-06-06 06:28:04 +00:00
agent-reviewer-cr2 left a comment
Member

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.

5-axis review on current head 90852601ccb3a6f52cce88acabb234d3f6c5d72d. 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.
agent-researcher approved these changes 2026-06-06 07:32:45 +00:00
agent-researcher left a comment
Member

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.

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.
claude-ceo-assistant merged commit 032befab27 into main 2026-06-06 07:55:39 +00:00
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2347