Repository navigation
refactor(sse): guard the KIE task-id and callback-url reads at their source - #8661
Merged
diegosouzapw merged 1 commit intoJul 27, 2026
Conversation
backryun
force-pushed
the
chore/ts7-types-kie-task-helpers
branch
from
July 26, 2026 20:53
64ad55e to
e35bdcd
Compare
backryun
force-pushed
the
chore/ts7-types-kie-task-helpers
branch
from
July 27, 2026 15:18
e35bdcd to
41c48cf
Compare
…source `kieExecutor.createTask()` returns `JsonObject` (`Record<string, unknown>`), so `createData.data` is `unknown` and the `createData?.data?.taskId` read that image, video and music generation each duplicated could not compile. The same three-line expression appeared verbatim in all three handlers. `open-sse/utils/kieTask.ts` already holds two helpers with exactly this shape — `normalizeKieTaskState()` and `parseKieResultJson()` both take `unknown`, guard with `isJsonObject()` and return a declared type. `getKieTaskId()` follows them, so the three handlers now share one guarded read instead of three unguarded ones. `getKieCallbackUrl()` took `KieCallbackBody`, a weak type (all properties optional). Passing a request body whose declared keys are `prompt` / `timeout_ms` / `poll_interval_ms` tripped TS2559 "no properties in common" at both music call sites. It receives arbitrary upstream request bodies, so it now takes `unknown` and guards the same way its neighbours do; `KieCallbackBody` had no other reference and is gone. Behaviour is unchanged. `isJsonObject()` rejects arrays and null exactly where optional chaining already yielded `undefined`, and the callers' `String(taskId)` coercion moved inside the helper, so a numeric id still reaches `pollTask()` as a string and a falsy id still takes the 502 branch. Fixes 5 of the 208 `tsc -p open-sse/tsconfig.json` diagnostics with no new ones: 3 x TS2339 `taskId` on `unknown`, 2 x TS2559 on `KieCallbackBody`. Refs diegosouzapw#8484
backryun
force-pushed
the
chore/ts7-types-kie-task-helpers
branch
from
July 27, 2026 15:35
41c48cf to
2030f70
Compare
Merged
HouMinXi
pushed a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 2, 2026
…source (diegosouzapw#8661) `kieExecutor.createTask()` returns `JsonObject` (`Record<string, unknown>`), so `createData.data` is `unknown` and the `createData?.data?.taskId` read that image, video and music generation each duplicated could not compile. The same three-line expression appeared verbatim in all three handlers. `open-sse/utils/kieTask.ts` already holds two helpers with exactly this shape — `normalizeKieTaskState()` and `parseKieResultJson()` both take `unknown`, guard with `isJsonObject()` and return a declared type. `getKieTaskId()` follows them, so the three handlers now share one guarded read instead of three unguarded ones. `getKieCallbackUrl()` took `KieCallbackBody`, a weak type (all properties optional). Passing a request body whose declared keys are `prompt` / `timeout_ms` / `poll_interval_ms` tripped TS2559 "no properties in common" at both music call sites. It receives arbitrary upstream request bodies, so it now takes `unknown` and guards the same way its neighbours do; `KieCallbackBody` had no other reference and is gone. Behaviour is unchanged. `isJsonObject()` rejects arrays and null exactly where optional chaining already yielded `undefined`, and the callers' `String(taskId)` coercion moved inside the helper, so a numeric id still reaches `pollTask()` as a string and a falsy id still takes the 502 branch. Fixes 5 of the 208 `tsc -p open-sse/tsconfig.json` diagnostics with no new ones: 3 x TS2339 `taskId` on `unknown`, 2 x TS2559 on `KieCallbackBody`. Refs diegosouzapw#8484
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…source (diegosouzapw#8661) `kieExecutor.createTask()` returns `JsonObject` (`Record<string, unknown>`), so `createData.data` is `unknown` and the `createData?.data?.taskId` read that image, video and music generation each duplicated could not compile. The same three-line expression appeared verbatim in all three handlers. `open-sse/utils/kieTask.ts` already holds two helpers with exactly this shape — `normalizeKieTaskState()` and `parseKieResultJson()` both take `unknown`, guard with `isJsonObject()` and return a declared type. `getKieTaskId()` follows them, so the three handlers now share one guarded read instead of three unguarded ones. `getKieCallbackUrl()` took `KieCallbackBody`, a weak type (all properties optional). Passing a request body whose declared keys are `prompt` / `timeout_ms` / `poll_interval_ms` tripped TS2559 "no properties in common" at both music call sites. It receives arbitrary upstream request bodies, so it now takes `unknown` and guards the same way its neighbours do; `KieCallbackBody` had no other reference and is gone. Behaviour is unchanged. `isJsonObject()` rejects arrays and null exactly where optional chaining already yielded `undefined`, and the callers' `String(taskId)` coercion moved inside the helper, so a numeric id still reaches `pollTask()` as a string and a falsy id still takes the 502 branch. Fixes 5 of the 208 `tsc -p open-sse/tsconfig.json` diagnostics with no new ones: 3 x TS2339 `taskId` on `unknown`, 2 x TS2559 on `KieCallbackBody`. Refs diegosouzapw#8484
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.
Part of the TS7 readiness campaign (#8484). One root cause, 5 diagnostics, zero new.
Root cause
kieExecutor.createTask()returnsJsonObject— i.e.Record<string, unknown>— socreateData.dataisunknown. Three handlers each carried the same unguarded read verbatim:open-sse/utils/kieTask.tsalready holds two helpers with exactly this shape:normalizeKieTaskState()andparseKieResultJson()both takeunknown, guard withisJsonObject(), and return a declared type.normalizeKieTaskState()even does the identicalrecord.datadance. So this fixes the read at its source rather than at each of the three call sites, following the neighbour rather than inventing a third idiom.Separately,
getKieCallbackUrl()tookKieCallbackBody— a weak type (every property optional). Passing a request body whose declared keys areprompt/timeout_ms/poll_interval_msshares no property with it, which is TS2559 at both music call sites. The function receives arbitrary upstream request bodies, so it now takesunknownand guards the same way its neighbours do.KieCallbackBodyhad no other reference in the repo and is removed.Diagnostics fixed
open-sse/handlers/imageGeneration.tstaskIdonunknownopen-sse/handlers/videoGeneration.tstaskIdonunknownopen-sse/handlers/musicGeneration.tsKieCallbackBodyMeasured as a line-number-agnostic diff of the complete
tsc -p open-sse/tsconfig.jsonerror set against a freshly re-measured base: 208 → 203, 5 fixed, 0 new. Also verified on top of the eight other open TS7 slices (160 → 155), where it applies without conflict.Behaviour is unchanged
isJsonObject()rejects arrays andnullin exactly the positions where optional chaining already producedundefined, so the fallback to a top-leveltaskIdis reached in the same cases.String(taskId)coercion moved inside the helper, so a numeric id still reachespollTask()as a string."",0, missing) still returns nothing and still takes the handlers' 502 branch.getKieCallbackUrl()only widens what it accepts; the three key casings, the blank-string rejection and the configured-URL fallback are untouched.Test plan
New
tests/unit/kie-task-helpers.test.ts— 10 tests covering every arm of the two helpers, including the ones the old inline expression never had coverage for:data.taskId, top-level fallback, nested-wins-over-top-leveldata(string / array /null) still falling through to the top level"",0) treated as absent, preserving the!taskIdguardnull,undefined, a string){}/ no-arg / non-object bodiesRegression run over the handlers this touches —
kie-executor-routing,image-generation-handler,image-generation-route,music-generation-handler,google-flow-video-4569,video-deepinfra-6653,alibaba-video-media,new-content-providers,audio-speech-handler,audio-transcription-handler,comfyui-baseurl-override-6928: 182 pass, 0 fail.Gates:
typecheck:coreclean,check:file-sizeOK,check:known-symbolsOK, ESLint clean on the touched files (the twono-explicit-anyreports inmusicGeneration.ts/videoGeneration.tsare the pre-existingcatch (err: any)entries already frozen at count 1 each ineslint-suppressions.json; this PR adds none).