test(secrets): cover compileAll and ScanBytes compile-error paths #3053

Merged
devops-engineer merged 2 commits from fix/1269-secrets-compile-error-tests into main 2026-06-19 04:30:01 +00:00
Member

Closes #1269.

PR #1255 left two unreachable code paths uncovered in workspace-server/internal/secrets:

  • compileAll error when a pattern regex is invalid.
  • ScanBytes returning the compile error instead of a Match.

Changes

  • Added TestCompileError and TestScanBytes_CompileErr.
  • Both tests inject an invalid regex into the package-level Patterns slice, reset compiledOnce/compileErr/compiledPatterns, and restore the original state after the test so later tests see the canonical pattern set.

Test plan

go test ./workspace-server/internal/secrets/... passes locally.

Fixes #1269

🤖 Generated with Claude Code

Closes #1269. PR #1255 left two unreachable code paths uncovered in `workspace-server/internal/secrets`: - `compileAll` error when a pattern regex is invalid. - `ScanBytes` returning the compile error instead of a `Match`. ## Changes - Added `TestCompileError` and `TestScanBytes_CompileErr`. - Both tests inject an invalid regex into the package-level `Patterns` slice, reset `compiledOnce`/`compileErr`/`compiledPatterns`, and restore the original state after the test so later tests see the canonical pattern set. ## Test plan `go test ./workspace-server/internal/secrets/...` passes locally. Fixes #1269 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agent-dev-a added 1 commit 2026-06-19 00:38:14 +00:00
test(secrets): cover compileAll and ScanBytes compile-error paths
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 7s
CI / Python Lint & Test (pull_request) Successful in 7s
E2E Peer Visibility (literal MCP list_peers) / detect-changes (pull_request) Successful in 6s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 5s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 6s
sop-checklist / review-refire (pull_request_target) Has been skipped
Harness Replays / detect-changes (pull_request) Successful in 7s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (local) (pull_request) Has been skipped
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 8s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 8s
CI / Detect changes (pull_request) Successful in 15s
qa-review / approved (pull_request_target) Failing after 8s
reserved-path-review / reserved-path-review (pull_request_target) Successful in 7s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (pull_request) Successful in 7s
security-review / approved (pull_request_target) Failing after 8s
E2E API Smoke Test / detect-changes (pull_request) Successful in 16s
sop-checklist / na-declarations (pull_request) N/A: (none)
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 16s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 2s
sop-checklist / all-items-acked (pull_request_target) Successful in 11s
CI / Canvas (Next.js) (pull_request) Successful in 2s
PR Diff Guard / PR diff guard (pull_request) Successful in 18s
CI / Canvas Deploy Status (pull_request) Successful in 1s
gate-check-v3 / gate-check (pull_request_target) Failing after 14s
template-delivery-e2e / detect-changes (pull_request) Successful in 15s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 21s
E2E Chat / detect-changes (pull_request) Successful in 22s
template-delivery-e2e / Template-asset delivery (fresh seo-agent — config+prompts via asset channel, seo-all via plugin reconcile) (pull_request) Successful in 1s
E2E Chat / E2E Chat (pull_request) Successful in 3s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 4s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (stub) (pull_request) Successful in 32s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (real image + MiniMax LLM, advisory) (pull_request) Successful in 36s
Harness Replays / Harness Replays (pull_request) Successful in 1m19s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m19s
CI / Platform (Go) (pull_request) Successful in 2m52s
CI / all-required (pull_request) Successful in 3s
sop-checklist / all-items-acked (pull_request) Compensated by status-reaper (non-required pull_request/pull_request_review governance shadow overridden by successful pull_request_target status; see .gitea/scripts/status-reaper.py)
4139fa1fa9
Issue #1269. PR #1255 left two unreachable code paths uncovered:
- compileAll error when a pattern regex is invalid.
- ScanBytes returning the compile error instead of a Match.

Add TestCompileError and TestScanBytes_CompileErr. Both mutate the package-level
Patterns slice to inject an invalid regex, reset compiledOnce/compileErr, and
restore the original state after the test so later tests see the canonical
pattern set.

Fixes #1269

🤖 Generated with [Claude Code](https://claude.com/claude-code)
agent-dev-a force-pushed fix/1269-secrets-compile-error-tests from c462fd811e to 4139fa1fa9 2026-06-19 00:38:14 +00:00 Compare
agent-dev-a added 1 commit 2026-06-19 00:46:16 +00:00
test(secrets): cover ScanString compile-error path
CI / Python Lint & Test (pull_request) Successful in 6s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 6s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 5s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 6s
sop-checklist / review-refire (pull_request_target) Has been skipped
Harness Replays / detect-changes (pull_request) Successful in 6s
E2E Peer Visibility (literal MCP list_peers) / detect-changes (pull_request) Successful in 11s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 10s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 8s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (local) (pull_request) Has been skipped
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2s
sop-checklist / all-items-acked (pull_request_target) Successful in 9s
CI / Detect changes (pull_request) Successful in 17s
E2E Chat / detect-changes (pull_request) Successful in 16s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 16s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (pull_request) Successful in 6s
PR Diff Guard / PR diff guard (pull_request) Successful in 16s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 18s
gate-check-v3 / gate-check (pull_request_target) Failing after 15s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 2s
CI / Canvas (Next.js) (pull_request) Successful in 2s
E2E Chat / E2E Chat (pull_request) Successful in 4s
CI / Canvas Deploy Status (pull_request) Successful in 1s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 4s
reserved-path-review / reserved-path-review (pull_request_target) Successful in 18s
template-delivery-e2e / detect-changes (pull_request) Successful in 24s
E2E API Smoke Test / detect-changes (pull_request) Successful in 29s
template-delivery-e2e / Template-asset delivery (fresh seo-agent — config+prompts via asset channel, seo-all via plugin reconcile) (pull_request) Successful in 1s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (stub) (pull_request) Successful in 46s
Harness Replays / Harness Replays (pull_request) Successful in 1m24s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (real image + MiniMax LLM, advisory) (pull_request) Successful in 46s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m20s
CI / Platform (Go) (pull_request) Successful in 3m59s
CI / all-required (pull_request) Successful in 4s
qa-review / approved (pull_request_target) Approved via pull_request_review trigger
security-review / approved (pull_request_target) Approved via pull_request_review trigger
qa-review / approved (pull_request_review) Successful in 10s
reserved-path-review / reserved-path-review (pull_request_review) Successful in 10s
security-review / approved (pull_request_review) Successful in 10s
audit-force-merge / audit (pull_request_target) Successful in 8s
d6a1423e5e
agent-reviewer-cr2 approved these changes 2026-06-19 04:28:36 +00:00
agent-reviewer-cr2 left a comment
Member

5-axis review on head d6a1423e:

APPROVED.

Correctness: the new tests exercise real compile-error paths by injecting invalid regex sources into Patterns, resetting compiledOnce, compileErr, and compiledPatterns, then asserting compileAll, ScanBytes, and ScanString surface the pattern-specific compile error with no Match. The cleanup restores the canonical pattern slice and clears the once state so later tests recompile cleanly.

Robustness: no t.Parallel use, so the package-global mutation is not racing within this test file. Cleanup is deferred in each mutating test. Security: test fixtures do not introduce real secrets and preserve the no-roundtrip match contract. Performance: test-only, negligible. Readability: helper and scenario names make the otherwise-global-state manipulation clear.

I could not run go test locally because this container does not have go installed, but Gitea shows CI / Platform (Go), secret scan, and the relevant core code checks successful on this head.

5-axis review on head d6a1423e: APPROVED. Correctness: the new tests exercise real compile-error paths by injecting invalid regex sources into `Patterns`, resetting `compiledOnce`, `compileErr`, and `compiledPatterns`, then asserting `compileAll`, `ScanBytes`, and `ScanString` surface the pattern-specific compile error with no `Match`. The cleanup restores the canonical pattern slice and clears the once state so later tests recompile cleanly. Robustness: no `t.Parallel` use, so the package-global mutation is not racing within this test file. Cleanup is deferred in each mutating test. Security: test fixtures do not introduce real secrets and preserve the no-roundtrip match contract. Performance: test-only, negligible. Readability: helper and scenario names make the otherwise-global-state manipulation clear. I could not run `go test` locally because this container does not have `go` installed, but Gitea shows CI / Platform (Go), secret scan, and the relevant core code checks successful on this head.
devops-engineer merged commit 9e86751bd5 into main 2026-06-19 04:30:01 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#3053