Repository navigation
Conversation
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.
Summary
Output files are only returned from the sandbox if their extension is in the hardcoded
SUPPORTED_EXTENSIONSset inapi/src/job.ts. Anything else is silently dropped, with no error and no log line. The only way to change the list was to patch the source and rebuild. For example,.mp4and.mp3have MIME entries but are not in the allow-list, and operators who want to restrict outputs (for example to text and Office files) have no option short of forking.This PR lets operators override both lists through environment variables. Defaults are unchanged.
Changes
CODEAPI_SUPPORTED_EXTENSIONS. Comma- or space-separated, leading dot optional, case-insensitive. When set, it replaces the built-in allow-list. Unset or blank falls back to the built-in list.CODEAPI_MIME_TYPES.ext=typepairs, comma- or space-separated (for example.epub=application/epub+zip,mp4=video/mp4). Entries are added toMIME_TYPE_BY_EXTENSIONand override existing entries on conflict. Malformed pairs are skipped.parseEnvExtensionsandparseEnvMimeTypes, each placed directly above the constant it feeds.env.example, with defaults copied from the current built-in values.isSupportedOutputFilenameandmimeTypeForare untouched. All three call sites of the filter pick up the change automatically.Why two variables
The allow-list and the MIME map are independent. An extension that is allowed but has no MIME entry is still delivered, but as
application/octet-stream. Many built-in extensions (.rtf,.scss,.tex,.json5, and others) already behave this way. Making the MIME map configurable means anything added to the allow-list can be given a correct type.Behavior notes
job.ts(the worker).CODEAPI_SUPPORTED_EXTENSIONSis a full replacement, not a merge. Archive extensions (.zip,.tar, and so on) should be left out when restricting file types, since they let sandbox code bypass the filter.*.badis kept as written and never matches a file.env.examplematch the built-ins today. Copying them into a.envpins the list, so later additions to the built-in list will not apply unless the variable is removed or updated.Testing
Suggested manual check: set
CODEAPI_SUPPORTED_EXTENSIONS=.txt .docx, writea.txt,b.docx,c.png, andd.pyto/mnt/data, and confirm that onlya.txtandb.docxare returned.