Skip to content

fix(workflows): log failures to record a failed schema apply (1/10) - #1360

Merged
Makisuo merged 1 commit into
mainfrom
refactor/backend-consistency-sweep
Oct 10, 2026
Merged

Makisuo merged 1 commit into
mainfrom
refactor/backend-consistency-sweep

Conversation

@Makisuo

@Makisuo Makisuo commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Part 1 of a backend consistency sweep (stack of 10). Each PR targets the one below it.

Rebuilt on top of #1353 (Postgres on effect-orm). The original msToDate/dateToMs sweep is obsolete now that timestamps are epoch ms natively, and its other small fixes moved to the layers that own them (org scoping in #1366, McpDecodeError in #1368, anomaly query contexts in #1363).

Changes

  • The schema-apply workflow's markFailed logs failures to record a failed run instead of dropping them silently. That silent path is what leaves a run stuck as "queued".

Verification

apps/api typecheck clean; ClickHouseSchemaApplyWorkflow.run.test.ts passes.

Summary by CodeRabbit

  • Bug Fixes
    • Schema update failures are now logged when related status or error-recording updates fail, while processing continues with best-effort behavior.

@maple-review-bot

maple-review-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 8/10 · likely safe to merge
370 mechanical conversions in auth and error paths read as exact equivalents; a few ErrorsService notification hunks were covered only by the fan-out.
quality 100/100 · no findings · tests partial · risk high · 1/1 new units observable

A behavior-preserving sweep: msToDate/dateToMs replace inline date conversions at the drizzle boundary across ~40 services, plus an org-scoped PR-link delete and a count(*)::int fix. Safe to merge; none of the open errors in registry.ts/dispatcher.ts are addressed.

  • msToDate/dateToMs replace inline new Date(ms)/.getTime() at the drizzle boundary
  • unlinkPullRequest now also filters errorIssuePullRequests.orgId on its delete
  • pr-review quota counts switch to sql<number>count(*)::int``
  • McpDecodeError carries message; anomaly timeseries queries get distinct contexts

Production impact

Open errors in the changed files
Issue Service Occurrences File
@maple/api/vcs/VcsSourceRepositoryNotFoundError maple-ai 68 apps/ai/src/mcp/tools/registry.ts
SandboxSpawnError maple-chat 52 apps/ai/src/mcp/dispatcher.ts
@maple/mcp/errors/McpQueryError maple-chat 42 apps/ai/src/mcp/tools/registry.ts
SandboxSpawnError maple-chat 29 apps/ai/src/mcp/dispatcher.ts
SandboxSpawnError maple-chat 23 apps/ai/src/mcp/dispatcher.ts
SandboxSpawnError maple-chat 17 apps/ai/src/mcp/dispatcher.ts
@maple/mcp/errors/McpQueryError maple-ai 15 apps/ai/src/mcp/tools/registry.ts
@maple/api/vcs/GithubAppError maple-chat 14 apps/ai/src/mcp/tools/registry.ts
SandboxSpawnError maple-chat 14 apps/ai/src/mcp/dispatcher.ts
@maple/http/errors/IntegrationsUpstreamError maple-chat 14 apps/ai/src/mcp/tools/registry.ts

After this merges, Maple checks whether they stop.

What was checked
  • Every substituted call is 1:1: dateToMs returns null exactly where the old ?.getTime() ?? null did (error-tick-persistence.ts:267)
  • Number(...) wraps both count(*) results, so ::int cannot break the quota comparisons (PrReviewService.ts:2051)
  • Each new query context names the query it labels (anomalyErrorSpikeTimeseriesQuery → anomalyErrorSpikeTimeseries)
Observability coverage: 1 of 1 changes observable
Change Kind Observable Evidence
schema-apply failure recording (2 previously silent writes) background yes Effect.ignore({ log: true, message }) at ClickHouseSchemaApplyWorkflow.run.ts:526,539 logs through the Effect logger instead of dropping the failure

0352cbc · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 12c49b56-fa76-4711-81e1-b7e7ba041e25

📥 Commits

Reviewing files that changed from the base of the PR and between 802d6f8 and 802d6f8.


📒 Files selected for processing (1)
  • apps/api/src/workflows/ClickHouseSchemaApplyWorkflow.run.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1efbdbe9-fce2-4d09-a816-72fc97028d15

📥 Commits

Reviewing files that changed from the base of the PR and between 0352cbc and 802d6f8.


📒 Files selected for processing (1)
  • apps/api/src/workflows/ClickHouseSchemaApplyWorkflow.run.ts

🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/api/src/workflows/ClickHouseSchemaApplyWorkflow.run.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.



📝 Walkthrough

Walkthrough

The schema-apply workflow now logs ignored failures from its failed-run update and settings error update. Both updates remain best-effort.

Changes

Schema-apply failure logging

Layer / File(s) Summary
Log ignored schema-apply update failures
apps/api/src/workflows/ClickHouseSchemaApplyWorkflow.run.ts
The workflow logs distinct messages when it cannot mark a run as failed or record the schema error in settings.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Refactor


Merge Risk: ⚪ Minimal · up to 802d6

The failure-path updates remain best-effort, with added logging. No issue requiring a fix before merge is established.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 42 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately describes the workflow error-logging change. It covers a real part of the pull request, although the main scope also includes broader Drizzle boundary consistency updates.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…of dropping them

markFailed best-effort writes swallowed their own failures silently, which is the path that leaves a run stuck as queued.
@Makisuo
Makisuo force-pushed the refactor/backend-consistency-sweep branch from 0352cbc to 802d6f8 Compare October 10, 2026 01:34
@Makisuo Makisuo changed the title refactor(backend): msToDate/dateToMs at the drizzle boundary and small consistency fixes (1/10) fix(workflows): log failures to record a failed schema apply (1/10) Oct 10, 2026
@maple-review-bot

maple-review-bot Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 9/10 · safe to merge
The two Effect.ignore call sites keep their old swallow-and-continue behavior, verified against the effect ignore implementation; the options form is inferred for 4.0.1 from the rc.112 source.
quality 100/100 · no findings · tests not needed · risk low · 1/1 new units observable

The two best-effort writes in the schema-apply workflow's markFailed now log their failure with the cause instead of dropping it silently. Behavior is otherwise unchanged and the diff is a single file, so it is safe to merge.

  • markFailed logs a failed run-status write instead of ignoring it silently
  • markFailed logs a failed OrgClickHouseSettings error write the same way
What was checked
  • Effect.ignore({ log: true, message }) is the v4 dual options form, not a self: isEffect(args[0]) is false for an options object (effect 4.0.0-rc.112 internal/effect.ts:3348)
  • With log set, a typed failure is logged with the cause and still ignored, while defects and interrupts are re-raised exactly as before (internal/effect.ts:3361)
  • ClickHouseSchemaApplyWorkflow.run.test.ts:130-164 still exercises the markFailed path, asserting status failed and the recorded error message
Observability coverage: 1 of 1 changes observable
Change Kind Observable Evidence
schema apply failure recording (markFailed) background job error path yes both bookkeeping writes now pass Effect.ignore({ log: true, message }), so the failure and its cause reach the log bridge (apps/api/src/workflows/ClickHouseSchemaApplyWorkflow.run.ts:531, :545)

802d6f8 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@Makisuo
Makisuo added this pull request to stack #1374 October 10, 2026 20:07
@Makisuo
Makisuo merged commit 38f4c39 into main Oct 10, 2026
39 checks passed
@Makisuo
Makisuo deleted the refactor/backend-consistency-sweep branch October 10, 2026 20:08
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.

1 participant