Repository navigation
Copy profile pictures on Workers and discover missing user info endpoints - #414
Merged
Merged
Conversation
…ints Picture requests passed redirect: "error", which Workers rejects before sending. The helpers caught the error and reported an unreadable picture, so hosted installations never copied a picture and cleared the provider URLs from sign-up. They now use redirect: "manual": a redirect is a non-2xx response, so it still reads as unreadable and its target is never asked. A workerd test checks that the requests leave the runtime. A company connection saved without a user info endpoint, for example one its provider added after registration, treated an ID token without a picture as no picture and removed the copy. The picture lookup now discovers a missing user info endpoint, with the same checks as sign-in. A failed discovery keeps the copy.
tnkuehne
added a commit
that referenced
this pull request
Nov 25, 2026
…ting (#416) Hosted Entra group search always failed with "The company directory could not be queried." Cloudflare Workers accepts only `redirect: "follow"` and `"manual"` and throws `TypeError: Invalid redirect value` for `"error"` before sending. Node accepts `"error"`, so the existing tests passed. #414 fixed the same problem for profile pictures. ## Changes - **Directory search** (`directory.ts`): the Entra token request and the Microsoft Graph group search use `redirect: "manual"`. Both failed independently on Workers. Their existing status checks reject a 3xx, so credentials never leave the directory's own endpoints. Google Workspace is unaffected; it takes the group-email path. - **Installation reporting** (`reporting.ts`): the PostHog transport uses `"manual"`. A 3xx fails the delivery, which the SDK handles like any failed send. With reporting enabled on Workers, no batch was ever sent. - **Failed responses**: their bodies are released in the background, so a cancellation that rejects or never settles cannot replace the reported error, keep a token Graph rejected, or hold later searches. Node-only calls (`telemetry.ts`, `runtime-management-node.ts`, the docs IndexNow script) keep `"error"`. ## Tests - `directory.worker.test.ts` runs the directory search in workerd through Miniflare and records outbound requests. It covers a successful token request and Graph search, and redirects from either, whose targets receive no request. Both tests fail with `"error"` and pass with `"manual"`. - `directory.test.ts`: a token error whose body cancellation rejects still reports the authentication error, and after a Graph 401 whose cancellation never settles the next search gets a new token. - `reporting.integration.test.ts` asserts the transport receives `redirect: "manual"`. A redirect case checks that the batch is attempted twice at the original URL, never at the target, and that both bodies are cancelled. It fails without the 3xx handling. - Type checks, Oxlint and Oxfmt pass. <!-- greptile_comment --> <!-- greptile_summary --> <h2><ruby><rp>Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues remain.</rp></ruby><a href="https://app.greptile.com/api/retrigger?id=120015466&sig=10a2a291fb6518d5ae673b992f4fe30c3a09187fb0919e3006ae3273e3a61aeb"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F416&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2> <!-- greptile-impact-verdict --> The PR appears safe to merge; no actionable issues remain. <details open><summary><h3>Summary</h3></summary> The PR makes directory search and installation reporting work on Workers without following redirects. - Entra group searches can reach Microsoft Graph from Workers. - Installation reports send batches from Cloudflare Workers. The previous unread-body concern is addressed: both directory failure branches call `cancel()`. No new actionable issues were found. </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (3) · Last reviewed commit: ["Release failed response bodies without w..."](19fe665) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
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.
Hosted installations never copied a profile picture after #407 and #409. Every sign-in cleared the provider URL from sign-up and left people with initials.
Cause
The picture fetches in
packages/auth-proxy/src/picture.tspassedredirect: "error". Cloudflare Workers accepts only"follow"and"manual"and throwsTypeError: Invalid redirect valuebefore sending. The helpers caught it and reported an unreadable picture, so image downloads, user info requests and the app proxy's discovery never left the Worker. Node accepts"error", so the existing tests passed.Changes
redirect: "manual". A redirect is a non-2xx response, so it still reads as unreadable and its target is never requested.userInfoEndpointtreated an ID token withoutpictureas no picture and removed the copy. This happens, for example, when the provider adds the endpoint after registration: same-issuer saves keep the three sign-in endpoints and skip discovery.prepareCompanyOidctakes{ discoverMissingUserInfo: true }, which also discovers when the user info endpoint is missing. Saved endpoints keep precedence and every endpoint gets the same checks as at sign-in.Tests
packages/auth-proxy/src/picture.worker.test.tsruns the shared helpers in workerd through Miniflare and records the outbound requests. It covers OIDC through discovery and user info, the Microsoft Graph photo, and redirects from user info and from a picture URL, whose targets receive no request. With"error"all three tests fail; with"manual"they pass.company-sso-plugin.integration.test.tsadds apartialconnection. It is registered while discovery advertises no user info endpoint, then the endpoint appears and a returning sign-in without an ID-token picture copies the user info picture. A failed discovery keeps the copy, and discovery that still omits the endpoint removes it. Without the source changes the case fails. Theregisteredconnection still refreshes from its saved endpoint without discovery.picture.test.tschecks the redirect mode and that a 302 reads as unreadable.packagesandapps/control-planesuites pass exceptruntime-errors.integration.test.ts, which needs a built server and fails onmainthe same way locally.

Confidence Score: 5/5
The PR appears safe to merge.Summary
Fixes picture downloads on Cloudflare Workers and finds missing company user info endpoints during picture lookup.
No actionable issues were found. Tests were inspected but not run during this review.
Reviews (1) · Last reviewed commit: "Copy profile pictures on Workers and dis..." · Reviewed by Greptile