Skip to content

refactor(sse): retag the Adobe Firefly IMS token-check union - #8638

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.49from
backryun:chore/ts7-types-adobe-firefly-token
Jul 27, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.49from
backryun:chore/ts7-types-adobe-firefly-token

Conversation

@backryun

Copy link
Copy Markdown
Contributor

Part of #8484. Type-only. 7 lines changed, 0 added. Clears adobeFireflyClient.ts — all 6 of its diagnostics, one cause.

Same root cause, fourth time

adobeFireflyClient.ts: TS2339: Property 'status' does not exist on type
  '{ ok: true; token: string; data: ImsTokenResponse } | { ok: false; status: number; error: string }'   x2
                        Property 'error' …                                                               x4

open-sse compiles with strictNullChecks: false, where a boolean-literal discriminant narrows the positive branch but leaves the negative one as the full union. So this:

if (authed.ok) { … } else { lastStatus = authed.status; lastError = authed.error; }

cannot see status/error in the else. Same shape as #8483, #8499 and #8531.

Retag, per the recorded rule

imsCheckToken is module-private — no export, no test reference — so this retags the discriminant rather than adding a type predicate. That is the rule written down on #8499: a predicate exists to avoid churning an exported shape and the assertions that depend on it, and there is no exported shape here.

 }): Promise<
-  | { ok: true; token: string; data: ImsTokenResponse }
-  | { ok: false; status: number; error: string }
+  | { state: "ok"; token: string; data: ImsTokenResponse }
+  | { state: "failed"; status: number; error: string }
 > {

plus the three returns and the two ifs. Seven lines, all replacements.

Kept inline on purpose

My first pass extracted a named ImsTokenCheck type with a doc comment explaining the narrowing. That took the file from 2317 to 2325 and failed check:file-size — this file is frozen with zero headroom.

So the union stays inline in the return position, which is line-for-line identical to what was there. Same lesson as #8557 on stream.ts: on a frozen file the explanation belongs in the commit message, not in the source.

Verification

208 → 202, zero new errors, on a line-number-agnostic diff of the full tsc error set.

  • npm run typecheck:core — clean
  • eslint — clean
  • check:file-size — OK (file unchanged in length)
  • 50/50 across the three Adobe Firefly suites

No test added — the arms were already covered

Checking each arm of the retagged union is now standard for these slices, and here it comes back clean. cookie exchange rejects guest IMS tokens drives both arms in a single flow:

request IMS response arm exercised
guest_allowed=false 400 "All session cookies are empty" state: "failed" — reads status and error
guest_allowed=true 200 + guest token state: "ok" — reads token, data

That test's assertion depends on the error text matching /session cookies are empty/i, which is one of the four reads that failed to typecheck — so the failed arm is not merely reachable, it is load-bearing in an existing assertion.

The same three suites pass on the parent commit, which is the evidence that the retag changes nothing observable.

Scope note

open-sse/services has 27 diagnostics left after this, but they do not share a cause — 13 files, at most 6 apiece, and the other 6-error file (browserBackedChat.ts) is six unrelated problems rather than one. Those slice individually. Tracked in #8484.

All 6 diagnostics in adobeFireflyClient.ts are one cause — the
`strictNullChecks: false` limitation this campaign has hit repeatedly (diegosouzapw#8483,
diegosouzapw#8499, diegosouzapw#8531): a boolean-literal discriminant narrows the positive branch but
leaves the negative one as the full union, so the `else` after
`if (authed.ok)` could not see `status` or `error`.

  imsCheckToken(): { ok: true; token; data } | { ok: false; status; error }
                -> { state: "ok"; … }        | { state: "failed"; … }

Retagged rather than fixed with a predicate: `imsCheckToken` is module-private
(no export, no test reference), which is the rule recorded on diegosouzapw#8499 —
predicates exist to avoid churning an exported shape, and there is none here.

208 -> 202, zero new, on a line-number-agnostic diff of the full tsc error set.

Kept the union inline in the return position instead of extracting a named
type: adobeFireflyClient.ts is frozen at 2317 lines with no headroom, and
extracting it (plus a doc comment) pushed the file to 2325 and failed
check:file-size. The diff is 7 lines changed, 0 added; the reasoning lives here.

No test added, and no gap to fill. "cookie exchange rejects guest IMS tokens"
already drives both arms in one flow: `guest_allowed=false` returns HTTP 400,
taking the failed arm and reading `status`/`error` (its assertion depends on the
"All session cookies are empty" text), then `guest_allowed=true` returns 200 and
takes the ok arm. 50/50 across the three Adobe Firefly suites; the same suites
pass on the parent commit, confirming the retag changes nothing observable.
@backryun
backryun force-pushed the chore/ts7-types-adobe-firefly-token branch from f30bebf to 5d3abfa Compare July 26, 2026 20:53
@diegosouzapw

Copy link
Copy Markdown
Owner

Validated in local merge-train /tmp/train1d-20260727-090022-suite.log on .113 @ 029cdf4215cf465f0e1716ac9f84a84692b1e881 (full unit suite green on CI-equivalent host)

@diegosouzapw
diegosouzapw merged commit dd34520 into diegosouzapw:release/v3.8.49 Jul 27, 2026
15 checks passed
@backryun
backryun deleted the chore/ts7-types-adobe-firefly-token branch July 27, 2026 14:37
@diegosouzapw diegosouzapw mentioned this pull request Jul 28, 2026
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.

2 participants