Skip to content

fix: preserve File-like metadata in toFile#1883

Open
pragnyanramtha wants to merge 1 commit into
openai:masterfrom
pragnyanramtha:pragnyan/preserve-file-like-metadata-tofile
Open

fix: preserve File-like metadata in toFile#1883
pragnyanramtha wants to merge 1 commit into
openai:masterfrom
pragnyanramtha:pragnyan/preserve-file-like-metadata-tofile

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Summary

  • preserve type and lastModified when toFile() receives non-native File-like objects
  • keep the native File fast path when no name/options override is requested
  • copy native File values when callers provide explicit metadata overrides
  • add upload helper coverage for preserving and overriding File-like metadata

Context

isFileLike() requires name, type, lastModified, and file methods, but toFile() rebuilt non-native File-like objects with only arrayBuffer() and name. That discarded useful upload metadata even though the input already exposed it.

Validation

  • ./node_modules/.bin/jest tests/uploads.test.ts --runInBand -> 11 passed, 3 snapshots passed
  • ./node_modules/.bin/prettier --check src/internal/to-file.ts tests/uploads.test.ts -> passed
  • ./node_modules/.bin/eslint src/internal/to-file.ts tests/uploads.test.ts -> passed
  • ./scripts/build -> passed
  • git diff --check -> passed

I also tried yarn lint; it progressed through Prettier, ESLint, and build, then failed in repo-wide typecheck because this checkout is missing existing example dependencies (@azure/identity, express, and next). The touched implementation and upload tests pass their focused checks.

Copilot AI review requested due to automatic review settings May 16, 2026 17:07
@pragnyanramtha pragnyanramtha requested a review from a team as a code owner May 16, 2026 17:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb874562b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/internal/to-file.ts Outdated
@pragnyanramtha pragnyanramtha force-pushed the pragnyan/preserve-file-like-metadata-tofile branch from eb87456 to f196b1c Compare May 16, 2026 17:46
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