Skip to content

Avoid the redirect mode Workers rejects in directory search and reporting - #416

Merged
tnkuehne merged 3 commits into
mainfrom
workers-redirect-mode
Nov 25, 2026
Merged

tnkuehne merged 3 commits into
mainfrom
workers-redirect-mode

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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.

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues remain.RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues remain.

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.

Reviews (3) · Last reviewed commit: "Release failed response bodies without w..." · Reviewed by Greptile

…ting

Workers accept only "follow" and "manual" redirects and reject
redirect: "error" before sending. Node accepts it, so tests passed while
hosted installations failed:

- Company directory group search: the Entra token request and the
  Microsoft Graph search both failed, so every hosted Entra group search
  reported that the directory could not be queried. Both now use
  "manual"; their status checks already reject a redirect, so
  credentials never leave the directory's own endpoints.
- Installation reporting, when enabled on Workers: batches never left.
  The transport uses "manual" and treats a redirect as a failed delivery.

A workerd test runs the directory search in Miniflare and checks that its
requests leave the runtime and that redirect targets are never requested.
Waiting for a body cancellation let a rejected cancellation replace the directory's error, skip dropping a token Graph rejected, and hold every later search behind a cancellation that never settles. Cleanup now runs in the background, in reporting too.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs f83a348 Nov 25 2026, 09:28 PM

@tnkuehne
tnkuehne merged commit d5e6069 into main Nov 25, 2026
18 checks passed
@tnkuehne
tnkuehne deleted the workers-redirect-mode branch November 25, 2026 22:07
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.

1 participant