Skip to content

Fix axios header type narrowing in GLM file upload (re-apply)#4

Merged
zhaiiker merged 1 commit into
mainfrom
fix/glm-axios-header-types
May 18, 2026
Merged

Fix axios header type narrowing in GLM file upload (re-apply)#4
zhaiiker merged 1 commit into
mainfrom
fix/glm-axios-header-types

Conversation

@kiro-agent
Copy link
Copy Markdown

@kiro-agent kiro-agent Bot commented May 18, 2026

This pull request was generated by @kiro-agent 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent


PR #3 was merged before the follow-up "Fix axios header type narrowing in GLM file upload" commit landed, so main still carries the broken line that blocks npm run dev:backend:

backend/proxy/adapters/glm.ts(224,7): error TS2322:
  Type 'string | number | true | string[] | AxiosHeaders' is not assignable to type 'string'.
  Type 'number' is not assignable to type 'string'.

In axios v1 response.headers is AxiosHeaders, so response.headers['content-type'] is typed as string | number | true | string[] | AxiosHeaders rather than string | undefined. Assigning that union to a string local fails strict type checking under ts-node.

This re-applies the one-line fix: narrow the value with a typeof === 'string' check, falling back to mime.lookup(filename) and the generic octet-stream default for non-string headers.

Test plan

  • git checkout main, pull this branch, run npm run dev and confirm the backend starts without TS errors.
  • Existing GLM file-upload code path unchanged for the common case where the server returns a string content-type header.

In axios v1 response.headers is AxiosHeaders, so
response.headers['content-type'] is typed as
string | number | true | string[] | AxiosHeaders. Assigning that
union to a string-typed local fails strict type checking under
ts-node, which is what blocks 'npm run dev:backend'.

Coerce through a typeof check so mimeType stays a string.

Note: the same fix was previously pushed to PR #3 as a follow-up
commit, but PR #3 was merged before that commit landed, so main
still carried the broken line. Re-applying it directly here.
@zhaiiker zhaiiker merged commit 8676527 into main May 18, 2026
@zhaiiker zhaiiker deleted the fix/glm-axios-header-types branch May 20, 2026 04:22
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