chore: plans for error handling middleware and error observability - #248
Merged
Merged
Conversation
ariskemper
marked this pull request as draft
February 6, 2026 16:53
ariskemper
force-pushed
the
chore/error-handling-observability-plans
branch
from
February 9, 2026 10:37
7fd65bc to
5f86714
Compare
- HTTP error boundary with RFC 9457 Problem Details responses - CLI error boundary with slug-based formatting - Error wrapping at boundaries (unknown errors → unknown-error slug) - Structured error logging (JSON in production, human-readable in dev) - Error metrics via OpenTelemetry counter with slug/category/status labels - Error tracing with span attributes and events - Migrate ErrorCollector to use slug registry categories - Deprecate legacy handleError/logAndThrow in favor of boundaries - Add plans for error handling middleware and error observability
ariskemper
force-pushed
the
chore/error-handling-observability-plans
branch
from
February 9, 2026 11:22
29f9d27 to
7403c08
Compare
ariskemper
marked this pull request as ready for review
February 9, 2026 11:25
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7403c08fe0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Extract errorToRFC9457Response as a shared export from http-error-boundary.ts and reuse it in route-executor.ts instead of duplicating the entire function. Also remove the duplicate wrapAsUnknownError and import wrapUnknownError from wrap-unknown.ts.
Previously, providing a context argument would silently drop error.context due to using `||` instead of merging. Now both are merged with caller context taking precedence.
Remove process.* fallbacks from isTTY/isDevelopment — this is a Deno project. Use isProduction() from build/config/environment.ts for consistency with logging.ts and the rest of the codebase.
Remove the errorRate histogram from error-instruments since it was created but never wired up anywhere. Also remove the awkward isVeryfrontErrorMiddleware alias from the errors barrel — isVeryfrontError is already exported from http-error.ts and the middleware version is identical.
Replace createErrorResponse with errorToRFC9457Response for env-aware filtering in the runtime-handler catch blocks. In production, detail is stripped from 5xx responses and stack traces are omitted, preventing internal error messages from leaking to clients.
kojiwakayama
force-pushed
the
chore/error-handling-observability-plans
branch
from
February 9, 2026 12:24
13c3f3d to
86235af
Compare
…ndary - Delete `handleError()` and `logAndThrow()` from error-handlers.ts (zero callers) - Remove from barrel exports and tests - Wire `cliErrorBoundary` into cli/router.ts (adds error metrics + OTel tracing) - Keep `wrapError`, `handleErrorWithFallback`, `retryWithBackoff` (still used)
Callers now use wrapWithContext directly from middleware/wrap-unknown. Removes the thin wrapError wrapper from error-handlers.ts, its tests, and barrel export. The 3 MDX callers updated to direct imports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up plans to #246 (error codes refactoring) and #247 (centralize scattered errors).
Execution Order
Plan A: Error Handling Middleware
Unified catch → serialize → respond pipeline at all boundaries.
Full plan:
plans/error_handling_middleware.mdTasks
Phase 1: HTTP error boundary
http-error-boundary.ts— catch all, serialize RFC 9457runtime-handler/index.ts(env-awareerrorToRFC9457Response)routing/api/route-executor.tsPhase 2: CLI error boundary
cli-error-boundary.ts— structured terminal outputPhase 3: Error wrapping
wrapUnknownError()— wrap plainErrorasunknown-errorslugwrapError()callers towrapWithContext(), delete wrapperPhase 4: Delete legacy
routing/api/error-handler.ts(zero imports after dedup)handleError(),logAndThrow(),wrapError()(zero callers)Phase 5: Verify
{ error }responses: only dev-only dashboard API and input-validation remain (breaking change to convert)cliErrorBoundaryPlan B: Error Observability
Structured logging, metrics, tracing, and alerting with slug-based errors.
Full plan:
plans/error_observability.mdTasks
Phase 1: Structured error logging
src/errors/logging.ts— JSON in production, human-readable in devhandleErrordeleted; remaininghandleErrorWithFallbackis a different pattern (catch-and-continue)Phase 2: Error metrics
error-instruments.ts—veryfront.error.count{slug,category,status}Phase 3: Error tracing
src/errors/tracing.ts—attachErrorToSpan()Phase 4: Migrate ErrorCollector
ErrorTypeenum with registry categoriesadd*Error()callers use new category systemPhase 5: Verify
veryfront_error_countFix Commits (review feedback)
handleAPIError→errorToRFC9457Response)logErrorcontext merge (preserve botherror.contextand caller context)isProduction()in CLI error boundary (remove Node.js fallbacks)errorRatehistogram and clean up re-exportshandleError/logAndThrow, wirecliErrorBoundaryinto CLI routerwrapErrorwithwrapWithContext, delete legacy wrapper