fix(http): guard relative baseURL — closes queue #21#77
Open
Goosterhof wants to merge 3 commits into
Open
Conversation
Deploying fs-packages with
|
| Latest commit: |
22da1c0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9b793e41.fs-packages.pages.dev |
| Branch Preview URL: | https://medic-queue-21-relative-base.fs-packages.pages.dev |
createHttpService(baseURL) previously called `new URL(baseURL)` directly, which throws an opaque native `TypeError: Invalid URL` on relative paths like '/api'. The error pointed at fs-http internals rather than the consumer's call site. This was latent for 6 days on entreezuil (PR #40 adoption -> PR #96 fix) because integration tests mock @script-development/fs-http and the real factory never ran in CI. Wrap the URL parse in a `parseBaseURL` helper that catches the native TypeError and re-throws a library-attributed Error naming the package (@script-development/fs-http), the function (createHttpService), the expectation (absolute baseURL with example), and the offending value (JSON.stringify of the input). Library-side fail-fast prevents the class for every fs-http adopter. Closes enforcement queue #21. Tests: 4 new guard cases (relative '/api', empty string, malformed strings 'not a url' / 'http://', happy-path regression for absolute URLs). Pre-fix all 3 negative cases failed with 'Invalid URL'; post-fix all 4 pass. Stash-and-rerun proof captured. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Patch bump — additive guard on previously-undefined behavior, no API change. Existing absolute-URL behavior unchanged. Consumer peer ranges already include `^0.3.0` (verified packages/adapter-store/package.json + packages/loading/package.json) — no peer-range cascade required. Lockfile regenerated; all @script-development/* still resolve to workspace symlinks (no nested registry copies). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
One-liner clarification on the existing baseURL row of the createHttpService API Reference table. The library-attributed error message remains the primary documentation surface for the failure path; this is the static-page corollary so consumers reading the API table before writing the call site see the constraint up front. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41373b5 to
22da1c0
Compare
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
new URL(baseURL)increateHttpServicewith a library-attributed error so relative paths like'/api'fail fast with a message that names the package, names the function, explains what's needed, and echoes the offending value — instead of the opaque nativeTypeError: Invalid URLthat points at fs-http internals.@script-development/fs-http0.3.0 → 0.3.1 (patch — additive guard on previously-undefined behavior, no API change).Seed Incident
Latent for 6 days on entreezuil (PR #40 adoption → PR #96 fix). Integration tests mock
@script-development/fs-http, so the real factory never ran in CI — the bug surfaced only at runtime in production. Library-side fail-fast prevents the class for every future fs-http adopter.Error Message Shape
Names the package, names the function, gives an actionable example, echoes the offending value (via
JSON.stringifyso empty strings, whitespace, and quoting are visible).Out of Scope (per orders)
streamRequest,withXSRFToken,withCredentials, or any other surface (Armorer is on a parallel docs-only XSRF PR; staying out of that lane).^0.3.0ranges; verified with grep onpackages/adapter-store/package.json+packages/loading/package.json.Stash-and-rerun Proof
Pre-fix run of the 4 new guard tests against unmodified source:
Post-fix: 4/4 pass. Bug reproduced as documented; fix verified to be what made the difference.
CI Gates (8/8 PASS locally)
npm auditnpm run format:checknpm run lintnpm run buildnpm run typechecknpm run lint:pkgnpm run test:coveragenpx stryker run(packages/http)unregister'sindex > -1check, unrelated. No regression of pre-existing survivors.Lockfile sanity:
package-lock.jsonregenerated; all 10node_modules/@script-development/*resolve to workspace symlinks ("link": true); no nested registry copies.Test Plan
TypeError: Invalid URL(proof captured)🤖 Generated with Claude Code