Skip to content

Simplify startup and improve error handling for incomplete credentials - #3

Merged
oblomov-dev merged 1 commit into
mainfrom
claude/zealous-gauss-xq5d3a
Oct 1, 2026
Merged

oblomov-dev merged 1 commit into
mainfrom
claude/zealous-gauss-xq5d3a

Conversation

@oblomov-dev

Copy link
Copy Markdown
Member

Summary

This change simplifies the development startup process and makes error handling more robust when service credentials are incomplete or invalid.

Key Changes

  • Simplified npm start: Changed npm start to run cds-serve --with-mocks directly, eliminating the need for a separate npm run mocked command. Updated README to reflect this as the primary development command.

  • Improved credential source detection: Enhanced the source_of() function in both sample apps to gracefully handle incomplete or invalid credentials:

    • Added support for wshost (WebSocket host) in addition to ashost and mshost
    • Added try-catch around URL parsing to handle missing or malformed URLs
    • Returns the service name when credentials are incomplete, allowing the actual query/call error to provide meaningful feedback to users
  • Updated documentation: Clarified in README that --with-mocks is the standard flag for development, explaining how it works with both cds watch and cds-serve, and that it's safely ignored in production profiles.

Implementation Details

The credential source detection now follows a defensive pattern: when credentials are incomplete or invalid, it returns a fallback value (the service name) rather than throwing an error. This allows downstream operations to fail with their own specific error messages, providing better user experience and debugging information.

https://claude.ai/code/session_01NVQ3JnU7R1QFQVgSoMK9RE

…l in the call

`npm start` ran cds-serve without --with-mocks, so the two samples of a
repository whose point is "it runs without the system" opened with an error
box each: "No credentials configured" and the missing RFC connector. The
mocks only came with `cds watch` (which needs @sap/cds-dk) or `npm run
mocked`. The start script now passes --with-mocks itself: in development
that is what cds watch passes, and in the production profile CAP ignores
the flag (features.with_mocks is off there), so the same script still
serves a deployment. The README's "Run it" says so; `mocked` goes, being
the same thing.

source_of( ) ran before the query and threw on credentials without a url -
a `.env` with a mistyped key - so the message box said "Invalid URL" instead
of CAP's own "url or destination must be configured in credentials". It now
names the service and lets the call report; the RFC one likewise falls back
to the service name when no host is configured, and knows wshost.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVQ3JnU7R1QFQVgSoMK9RE
@oblomov-dev
oblomov-dev merged commit f91ce48 into main Oct 1, 2026
1 check passed
@oblomov-dev
oblomov-dev deleted the claude/zealous-gauss-xq5d3a branch October 1, 2026 02:30
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.

2 participants