Simplify startup and improve error handling for incomplete credentials - #3
Merged
Merged
Conversation
…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
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.
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 startto runcds-serve --with-mocksdirectly, eliminating the need for a separatenpm run mockedcommand. 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:wshost(WebSocket host) in addition toashostandmshostUpdated documentation: Clarified in README that
--with-mocksis the standard flag for development, explaining how it works with bothcds watchandcds-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