René's URL Explorer Experiment


Title: fix(api): answer upstream MCP, OAuth, and id-conflict failures with 4xx; keep PII keep-alive past the load balancer by waleedlatif1 · Pull Request #9210 · simstudioai/sim · GitHub

Open Graph Title: fix(api): answer upstream MCP, OAuth, and id-conflict failures with 4xx; keep PII keep-alive past the load balancer by waleedlatif1 · Pull Request #9210 · simstudioai/sim

X Title: fix(api): answer upstream MCP, OAuth, and id-conflict failures with 4xx; keep PII keep-alive past the load balancer by waleedlatif1 · Pull Request #9210 · simstudioai/sim

Description: Summary MCP tool discovery: a registered server that is unreachable, times out, or is in its post-failure cooldown now answers 422 and logs at warn, instead of 502/503 + ERROR. It is the registered server's fault, not Sim's, and the request itself was valid. 422 is what the MCP route family already uses when an upstream can't complete the operation (the DCR-unsupported branch in oauth/start). The repo uses no 424 anywhere. 400 would blame the request. Other discovery failures keep categorizeError's status and log at error only for 5xx. categorizeError itself is unchanged, so tool execution (lib/internal/mcp/execute-tool.ts) and server refresh keep their mapping. The v2 tools endpoint has its own typed policy (documented 503) and is untouched. McpClient connect and ping failures log at warn. MCP OAuth start: any OAuthError from the authorization server answers 422 with the same surfaced message. Previously it was 500 + ERROR, plus a second ERROR from timedStep. The refusal is caught inside the bounded step, like the redirect signal, so timedStep no longer logs it either. This deliberately includes ServerError: SDK 1.31.0 parseErrorResponse maps any error code it doesn't know (RFC 7591 invalid_redirect_uri among them) and any non-spec body to ServerError, so filtering on the subclass would miss the refusals we actually get. Non-OAuth failures (DB, decryption) stay 500 with the generic message. POST /api/workflows: a 23505 on workflow_pkey (a caller-supplied id that already exists) is now a conflict → 409, not a 500. It also no longer triggers a deduplicate-name retry, and it logs the id at warn. The name-index handling is unchanged. PII service: uvicorn's 5s keep-alive default closed idle connections that the load balancer (300s idle timeout) was still reusing. A request sent on one of those connections got an instant load-balancer 502. The entrypoint now sets --timeout-keep-alive 310 (overridable with PII_TIMEOUT_KEEP_ALIVE), so the load balancer is always the side that closes. PII mask client: the mask-batch route rejects any NUL in a body, so one log string with a NUL scrubbed its whole chunk. The client now sends texts through sanitizeForJsonb (NUL and unpaired surrogates → U+FFFD). The substitution is length-preserving, and text without either character is unchanged. Type of Change Bug fix Testing app/api/mcp/tools/discover/route.test.ts (real handler): connection error → 422, cooldown → 422, a non-server error stays 500. Red on the old code (502/503). app/api/mcp/oauth/start/route.test.ts (real handler, real SDK registerClient with an injected fetch): unknown RFC 7591 code, a typed OAuth code, and a non-spec body all → 422 with the server message. A non-OAuth failure stays 500. Red on the old code (500 ×3). lib/guardrails/mask-client.test.ts: the client is driven through the real mask-batch route. A NUL string is masked instead of scrubbing its chunk, and NUL-free text reaches Presidio byte-identical. Red on the old code (2 strings scrubbed). lib/workflows/orchestration/create-workflow-with-state.integration.ts (real Postgres): a taken id → conflict and the original row is untouched, the deduplicate path with a taken id → conflict, and the exact-name conflict is unchanged. Red on the old code (2 failures, internal). Entrypoint arg list checked with a stub uvicorn (defaults and env overrides). --timeout-keep-alive default of 5 confirmed in uvicorn 0.49.0. bun run lint, check:test-patterns, check:comment-hygiene. Existing MCP, workflow, and guardrails suites pass. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing (new tests pass the test-audit authoring gate) No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary MCP tool discovery: a registered server that is unreachable, times out, or is in its post-failure cooldown now answers 422 and logs at warn, instead of 502/503 + ERROR. It is the registere...

X Description: Summary MCP tool discovery: a registered server that is unreachable, times out, or is in its post-failure cooldown now answers 422 and logs at warn, instead of 502/503 + ERROR. It is the registere...

Opengraph URL: https://github.com/simstudioai/sim/pull/9210

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6971ccfa-0575-682d-8cfd-bc235f5e0394
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id809A:2E3401:1B0F72:260EDC:6AFB7A0D
html-safe-noncee3f293a0ebfbb85e286a205547e3bc9311e7c6c9297a37a0561e8300d0d6f22c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDlBOjJFMzQwMToxQjBGNzI6MjYwRURDOjZBRkI3QTBEIiwidmlzaXRvcl9pZCI6IjIwNjk5OTQ1MjQxNTAyOTkxNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9064c380a5ff3219ba1201434ced47b275061d44bfbf4045d6f47fc5519802ec
hovercard-subject-tagpull_request:4913698690
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/9210/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary MCP tool discovery: a registered server that is unreachable, times out, or is in its post-failure cooldown now answers 422 and logs at warn, instead of 502/503 + ERROR. It is the registere...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0e29e7974fdda2feeaf5c891efd4b23b0734b23480232b62c7bdef13f40b5b48
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2e8872b770cc4d5d0cc1f2026afab747a268e2ce
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/9210/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F9210%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F9210%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/9210/files
Reloadhttps://github.com/simstudioai/sim/pull/9210/files
Reloadhttps://github.com/simstudioai/sim/pull/9210/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests202 (202)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/upstream-failure-statuseshttps://github.com/simstudioai/sim/tree/fix/upstream-failure-statuses
Conversation 10 https://github.com/simstudioai/sim/pull/9210
Commits 2 https://github.com/simstudioai/sim/pull/9210/commits
Checks 52 https://github.com/simstudioai/sim/pull/9210/checks
Files changed https://github.com/simstudioai/sim/pull/9210/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9210/files
fix(api): answer upstream MCP, OAuth, and id-conflict failures with 4xx; keep PII keep-alive past the load balancer https://github.com/simstudioai/sim/pull/9210/files#top
Show all changes 2 commits https://github.com/simstudioai/sim/pull/9210/files
897a0e0 fix(api): answer upstream MCP, OAuth, and id-conflict failures with 4… waleedlatif1 Oct 18, 2026 https://github.com/simstudioai/sim/pull/9210/commits/897a0e03b72f1df19cc1325d557319d8f02870d7
cf47f89 fix(mcp): treat tools/list timeouts and HTTP errors as an unavailable… waleedlatif1 Oct 18, 2026 https://github.com/simstudioai/sim/pull/9210/commits/cf47f894656f36ee5b7f3575603f0ad8a3b7537d
Clear filters https://github.com/simstudioai/sim/pull/9210/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9210/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9210/files
route.test.ts https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
route.ts https://github.com/simstudioai/sim/pull/9210/files#diff-c39ea44b90f19a68eac78450a1dcd4c067a80c8639393cc2cb66f7566da41ba0
route.test.ts https://github.com/simstudioai/sim/pull/9210/files#diff-36a48f839a088f6be164e3dfc5fc4cf6ce023675ef1930da056fb2ef0a43c2b0
route.ts https://github.com/simstudioai/sim/pull/9210/files#diff-996c743d5e8a330e59c381233d961abe818c086daa5c27329e3634a8d46f264b
utils.ts https://github.com/simstudioai/sim/pull/9210/files#diff-f1d8fff7129577a012b2653887f7f8328ca69fcea3817eea8594cf9b4dad69e9
mask-client.test.ts https://github.com/simstudioai/sim/pull/9210/files#diff-77561016b13dfbca2b2b243f475008029e59db8a8ac2e2eab47fb1a99f002612
mask-client.ts https://github.com/simstudioai/sim/pull/9210/files#diff-8e6aeec5304a44062b4a7ecf04cf296b0f71d0ca7ec9567c89bf0718dbfffa97
client.test.ts https://github.com/simstudioai/sim/pull/9210/files#diff-3c669f1cfdbdbd74ae67141932035c61beea21909c92d6e0b8ad9f26b569dcab
client.ts https://github.com/simstudioai/sim/pull/9210/files#diff-25cb24353597fac644145b37622d21ec7315282c29ccb1c4275f3ccb46441e1a
utils.ts https://github.com/simstudioai/sim/pull/9210/files#diff-3e3a2ab59257f1f643c0bfcbb46e4acb6a9ac29cb0906aa9c4d9d9a05e8852a4
create-workflow-with-state.integration.ts https://github.com/simstudioai/sim/pull/9210/files#diff-9b9fa6e89f0882888432e6bcd70345437f38070b1dfea583a2e4e396f88a4f1a
workflow-lifecycle.ts https://github.com/simstudioai/sim/pull/9210/files#diff-95e7538e4d87787269e3bed0a51a8a851beedcc654a68a8d4a6ec05281ad0876
pii-entrypoint.sh https://github.com/simstudioai/sim/pull/9210/files#diff-729ebf7a38b88f8c9d8f1181aab7df96f92c2f00075287e486b5b124cea99bbc
check-test-types.baseline.json https://github.com/simstudioai/sim/pull/9210/files#diff-3f0e52298332b82e821be5c9210ddb89bb43ab248c2db79c27e6a783dbfe9e36
apps/sim/app/api/mcp/oauth/start/route.test.tshttps://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
View file https://github.com/simstudioai/sim/blob/cf47f894656f36ee5b7f3575603f0ad8a3b7537d/apps/sim/app/api/mcp/oauth/start/route.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9210/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
https://github.com/simstudioai/sim/pull/9210/files#diff-463b39d876cd41f35548f691cfc783b9d86c5d9e558957d295ce0570f52c4cf5
apps/sim/app/api/mcp/oauth/start/route.tshttps://github.com/simstudioai/sim/pull/9210/files#diff-c39ea44b90f19a68eac78450a1dcd4c067a80c8639393cc2cb66f7566da41ba0
View file https://github.com/simstudioai/sim/blob/cf47f894656f36ee5b7f3575603f0ad8a3b7537d/apps/sim/app/api/mcp/oauth/start/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9210/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9210/files#diff-c39ea44b90f19a68eac78450a1dcd4c067a80c8639393cc2cb66f7566da41ba0
https://github.com/simstudioai/sim/pull/9210/files#diff-c39ea44b90f19a68eac78450a1dcd4c067a80c8639393cc2cb66f7566da41ba0
https://github.com/simstudioai/sim/pull/9210/files#diff-c39ea44b90f19a68eac78450a1dcd4c067a80c8639393cc2cb66f7566da41ba0
https://github.com/simstudioai/sim/pull/9210/files#diff-c39ea44b90f19a68eac78450a1dcd4c067a80c8639393cc2cb66f7566da41ba0
apps/sim/app/api/mcp/tools/discover/route.test.tshttps://github.com/simstudioai/sim/pull/9210/files#diff-36a48f839a088f6be164e3dfc5fc4cf6ce023675ef1930da056fb2ef0a43c2b0
View file https://github.com/simstudioai/sim/blob/cf47f894656f36ee5b7f3575603f0ad8a3b7537d/apps/sim/app/api/mcp/tools/discover/route.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9210/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9210/files#diff-36a48f839a088f6be164e3dfc5fc4cf6ce023675ef1930da056fb2ef0a43c2b0
https://github.com/simstudioai/sim/pull/9210/files#diff-36a48f839a088f6be164e3dfc5fc4cf6ce023675ef1930da056fb2ef0a43c2b0
apps/sim/app/api/mcp/tools/discover/route.tshttps://github.com/simstudioai/sim/pull/9210/files#diff-996c743d5e8a330e59c381233d961abe818c086daa5c27329e3634a8d46f264b
View file https://github.com/simstudioai/sim/blob/cf47f894656f36ee5b7f3575603f0ad8a3b7537d/apps/sim/app/api/mcp/tools/discover/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9210/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9210/files#diff-996c743d5e8a330e59c381233d961abe818c086daa5c27329e3634a8d46f264b
https://github.com/simstudioai/sim/pull/9210/files#diff-996c743d5e8a330e59c381233d961abe818c086daa5c27329e3634a8d46f264b
https://github.com/simstudioai/sim/pull/9210/files#diff-996c743d5e8a330e59c381233d961abe818c086daa5c27329e3634a8d46f264b
https://github.com/simstudioai/sim/pull/9210/files#diff-996c743d5e8a330e59c381233d961abe818c086daa5c27329e3634a8d46f264b
Please reload this pagehttps://github.com/simstudioai/sim/pull/9210/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9210/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.