Skip to content

fix: wrap repo service errors in UserError for cleaner output#88

Merged
github-actions[bot] merged 1 commit intomainfrom
wrap-repo-service-errors-in-UserError
Jan 31, 2026
Merged

fix: wrap repo service errors in UserError for cleaner output#88
github-actions[bot] merged 1 commit intomainfrom
wrap-repo-service-errors-in-UserError

Conversation

@stack72
Copy link
Copy Markdown
Contributor

@stack72 stack72 commented Jan 31, 2026

  • Wrap "repository already initialized" and "not a swamp repository" errors in UserError to suppress stack traces
  • These are expected user-facing conditions where the stack trace is noise

Test plan

  • deno check passes
  • deno run test src/domain/repo/ passes

- Wrap "repository already initialized" and "not a swamp repository" errors in UserError to suppress stack traces
- These are expected user-facing conditions where the stack trace is noise

### Test plan

- deno check passes
- deno run test src/domain/repo/ passes
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR correctly wraps repository initialization errors in UserError to suppress stack traces for expected user-facing conditions. The changes align well with the established error handling pattern in this codebase.

Analysis

Code Quality: ✅

  • Clean, minimal change that follows existing patterns
  • UserError is already used throughout the codebase (16 files) for similar purposes
  • The error handling in src/presentation/output/error_output.tsx:32-33 properly detects UserError instances and suppresses stack traces

TypeScript Compliance: ✅

  • No any types
  • Uses named imports correctly
  • Type-safe implementation

Test Coverage: ✅

  • Existing tests at repo_service_test.ts:115-129 and repo_service_test.ts:183-194 will continue to pass because UserError extends Error
  • The assertRejects calls check for Error type and error message content, both of which are preserved

DDD Principles: ✅

  • UserError is appropriately defined in the domain layer (src/domain/errors.ts)
  • The separation between internal errors (show stack) and user-facing errors (no stack) is a valid domain concept

Security: ✅

  • No security concerns - this change actually improves UX by reducing noise in error output

Suggestions (Non-blocking)

  1. Consider stronger test assertions: The tests could be updated to assert UserError specifically instead of Error to document the intended behavior more explicitly. However, this is optional since the current tests correctly verify the error messages.

LGTM!

@github-actions github-actions bot merged commit eb9e4da into main Jan 31, 2026
3 checks passed
@github-actions github-actions bot deleted the wrap-repo-service-errors-in-UserError branch January 31, 2026 02:04
stack72 added a commit that referenced this pull request Apr 13, 2026
forEach.in is evaluated synchronously, but async CEL functions
(data.latest, data.findByTag, data.findBySpec, data.query) return
Promises that coerceBigInts silently converts to {}, causing forEach
to expand zero steps with no error. Add Promise detection in
CelEvaluator.evaluate before coerceBigInts runs, and wrap the error
in expandForEachSteps and libswamp evaluate.ts with a UserError that
names the expression and points to the nested workflow workaround.

Closes: swamp-club #88

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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