Skip to content

fix: normalize URLs in deprecateStaleResources to prevent false deprecation#696

Open
craigbidenbot[bot] wants to merge 1 commit intomainfrom
craig/fix-deprecate-url-normalization
Open

fix: normalize URLs in deprecateStaleResources to prevent false deprecation#696
craigbidenbot[bot] wants to merge 1 commit intomainfrom
craig/fix-deprecate-url-normalization

Conversation

@craigbidenbot
Copy link
Copy Markdown
Contributor

@craigbidenbot craigbidenbot bot commented Mar 9, 2026

Summary

Server listings disappear after re-registering via discovery because deprecateStaleResources compares raw discovery URLs against DB-stored URLs, which have had query params stripped by registerResource. The mismatch causes all existing resources to be falsely deprecated.

Changes

  • Add normalizeResourceUrl helper that strips query params (matching registerResource's canonical form)
  • Apply normalization + dedup to activeResourceUrls before the notIn comparison in deprecateStaleResources

Root Cause

registerResource stores URLs with urlObj.search = '' (query params stripped), but deprecateStaleResources compared against raw discovery URLs. When discovery URLs differed from the stored canonical form, the notIn clause failed to match existing resources → they were all deprecated → origin disappeared from listings.

Test Plan

  • Re-register gateway.spraay.app via the Add Server page — existing resources should persist
  • Register a server whose discovery doc contains URLs with query params — no false deprecation
  • Verify stale resources (genuinely removed from discovery) are still deprecated correctly

Fixes #693

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
x402scan Ready Ready Preview, Comment Mar 14, 2026 10:21pm

…form

registerResource strips query params (urlObj.search = '') before storing,
but deprecateStaleResources compared raw discovery URLs against the DB.
This mismatch caused all existing resources to be falsely deprecated when
re-registering via discovery, making the server listing disappear.

Fixes #693
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.

Server listing disappeared after bulk endpoint registration — gateway.spraay.app

1 participant