Skip to content

fix: the unidentifiable-upload test is not random - #879

Open
blaipr wants to merge 1 commit into
mainfrom
fix/the-unidentifiable-upload-test-is-not-random
Open

fix: the unidentifiable-upload test is not random#879
blaipr wants to merge 1 commit into
mainfrom
fix/the-unidentifiable-upload-test-is-not-random

Conversation

@blaipr

@blaipr blaipr commented Aug 24, 2026

Copy link
Copy Markdown
Member

testUnidentifiableContentFallsBackToTheDeclaredType built its payload as a fixed prefix
followed by random_bytes(48), and handed it to libmagic. Most of the time libmagic gives
up and answers application/octet-stream, which is the inconclusive answer the test is
about — the upload then falls back to the declared type and succeeds.

Sometimes it does not. Measured over 3,000 payloads on this image, 16 came back as
image/x-tga: about one run in two hundred. A recognised type is not inconclusive, so the
declared application/pdf is not used, image/x-tga is not on the allow-list, and the upload
is refused — the run fails with 400 where it wanted 200, on whichever pull request
happened to be open when it landed.

This is the same shape as the faker randomNumber() fixture already recorded here: a
value drawn at random that is almost always in range, and occasionally is not. The payload
is fixed now, and confirmed inconclusive.

Found because it failed CI on an unrelated change, and reproduced by measuring rather than
by re-running until it happened again.

`testUnidentifiableContentFallsBackToTheDeclaredType` built its payload as a fixed prefix
followed by `random_bytes(48)`, and handed it to libmagic. Most of the time libmagic gives
up and answers application/octet-stream, which is the inconclusive answer the test is
about — the upload then falls back to the declared type and succeeds.

Sometimes it does not. Measured over 3,000 payloads on this image, 16 came back as
image/x-tga: about one run in two hundred. A recognised type is not inconclusive, so the
declared application/pdf is not used, image/x-tga is not on the allow-list, and the upload
is refused — the run fails with 400 where it wanted 200, on whichever pull request
happened to be open when it landed.

This is the same shape as the faker `randomNumber()` fixture already recorded here: a
value drawn at random that is almost always in range, and occasionally is not. The payload
is fixed now, and confirmed inconclusive.

Found because it failed CI on an unrelated change, and reproduced by measuring rather than
by re-running until it happened again.
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.

1 participant