mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
fix(tool-access): keep OAuth redirect-policy refusals out of Sentry
An authorization server that answers dynamic client registration with 400 invalid_redirect_uri is applying its own redirect policy. Paperclip only sends callbacks built from trusted origins and already returns a 502 with remediation, so stop reporting this one case as a crash. Other registration 400s, unknown codes and non-400 rejections stay reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
66a8aa7f7e
commit
97a4b46447
3 files changed
+51
-1
No files matched your search
@@ -75,6 +75,31 @@ describe("OAuth dynamic client registration failure reporting", () => {
|
||||
expect(JSON.stringify(oauthProviderFailureDiagnosticsFor(reported))).not.toContain(PROVIDER_CANARY);
|
||||
});
|
||||
|
||||
it("answers a provider's 400 invalid_redirect_uri with its remediation and no crash report", async () => {
|
||||
const res = await request(createApp(400, { error: "invalid_redirect_uri", error_description: PROVIDER_CANARY }))
|
||||
.post("/register");
|
||||
|
||||
expect(res.status).toBe(502);
|
||||
expect(res.body).toMatchObject({
|
||||
error: "The authorization server rejected Paperclip's callback URL.",
|
||||
code: "oauth_dynamic_client_registration_failed",
|
||||
details: { providerError: "invalid_redirect_uri", status: 400 },
|
||||
});
|
||||
expect(JSON.stringify(res.body)).not.toContain(PROVIDER_CANARY);
|
||||
expect(captureExceptionMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
["a 422 invalid_redirect_uri", 422, { error: "invalid_redirect_uri" }],
|
||||
["a 400 with an unrecognized error code", 400, { error: "redirect_rejected_by_policy" }],
|
||||
["a 400 with no error code", 400, {}],
|
||||
])("still reports %s", async (_label, status, body) => {
|
||||
const res = await request(createApp(status, body)).post("/register");
|
||||
|
||||
expect(res.status).toBe(502);
|
||||
expect(captureExceptionMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("still reports a successful response with unusable client metadata", async () => {
|
||||
const res = await request(createApp(201, { redirect_uris: [] })).post("/register");
|
||||
|
||||
|
||||
Reference in new issue
Block a user