project-nomad/admin
Chris 543ae5671a
fix(chat): accept image attachments whatever the case of their extension
A file named IMG_0001.JPG was refused with "is not a valid image upload",
although the page lets it be attached. The chat route gave the upload parser a
list of extensions, and @adonisjs/bodyparser compares an extension
case-sensitively, so only jpg, jpeg, png and webp in lower case were valid.

The parser now checks size only, and normalizeChatImage checks the parser's
extname against the same list without regard to case. The extname is the type
the parser read from the file's bytes when the name has no extension or a
lower-case one it recognizes, and the extension as written otherwise. A refusal
is the same 422.

The options move to CHAT_IMAGE_UPLOAD_OPTIONS in chat_images.ts, so a test can
use the controller's value; size is MAX_CHAT_IMAGE_BYTES, the same 8 MB.

Behavior, from 62 combinations of file name and content run through the real
parser and normalizeChatImages on dev and on this change: nothing that was
accepted is refused, 39 are unchanged, and every difference comes from an
upper-case or mixed-case extension. Upper-case and mixed-case JPEG, PNG and WebP
names are accepted, and so is an animated PNG named .PNG: the parser does not
read the bytes behind an upper-case name, so sharp takes its first frame, as it
already does for one named .jpeg. A GIF, TIFF, AVIF or SVG named .JPG or .PNG
gets 415 from sharp instead of 422. Text, PDF and one-byte files named .JPG or
.PNG keep their 422, and the message changes from "is not a valid image upload"
to "could not be decoded as an image".

Tests: tests/unit/chat_image_upload.spec.ts sends files through the real
multipart parser with those options, then normalizeChatImages. It fails if the
list goes back into the parser options, if the extension check is dropped, if it
is made case-sensitive, or if a file with no extname is let through. The
hand-built files in chat_images.spec.ts and ollama_controller_chat.spec.ts gain
an extname, as the parser sets one. The 13 tests in chat_image_upload.spec.ts
and chat_images.spec.ts pass, and typecheck shows the same 11 errors as dev,
from packages missing or older in my checkout.
Not run: the controller in a running install, and its Japa spec (openai is
missing in my checkout); that spec's hand-built file was checked against
normalizeChatImages directly.
2026-10-08 21:05:59 +00:00
..
app fix(chat): accept image attachments whatever the case of their extension 2026-10-08 21:05:59 +00:00
bin feat: curated content system overhaul 2026-02-11 15:44:46 -08:00
commands feat(AI): add opt-in relevance check for off-topic retrieval 2026-09-29 15:54:41 -07:00
config fix: lazy-connect + retry for ioredis to avoid blocked startup 2026-06-23 17:40:10 +00:00
constants fix(gpu): detect Ollama CPU fallback on AMD and offer the right fix 2026-09-29 15:54:41 -07:00
database fix(translate): download every released language, and list them in the docs 2026-10-05 14:19:27 -07:00
docs docs(release): finalize v1.35.1 release notes [skip ci] 2026-10-05 22:30:13 +00:00
inertia chore(branding): replace the retired N.O.M.A.D. badge with the new logo 2026-09-29 15:54:41 -07:00
providers fix(gpu): detect Ollama CPU fallback on AMD and offer the right fix 2026-09-29 15:54:41 -07:00
public chore(branding): replace the retired N.O.M.A.D. badge with the new logo 2026-09-29 15:54:41 -07:00
resources chore: standardize brand name to Project NOMAD, retire backronym 2026-08-04 03:37:32 +00:00
scripts refactor(drug-reference): make collections JSON the single source for curated data (#1130) 2026-08-04 03:38:35 +00:00
start feat(zim): let users browse the Kiwix library in any language 2026-09-29 15:54:41 -07:00
tests fix(chat): accept image attachments whatever the case of their extension 2026-10-08 21:05:59 +00:00
types fix(gpu): detect Ollama CPU fallback on AMD and offer the right fix 2026-09-29 15:54:41 -07:00
util Add offline FDA drug reference (labels, interaction view, conditions, remedies) (#1040) 2026-08-04 03:38:33 +00:00
views chore: standardize brand name to Project NOMAD, retire backronym 2026-08-04 03:37:32 +00:00
.editorconfig feat: initial commit 2025-06-29 15:51:08 -07:00
.env.example feat(creator-packs): gated per-creator video packs, offline via Kiwix (#1106) 2026-08-04 03:38:27 +00:00
ace.js feat: initial commit 2025-06-29 15:51:08 -07:00
adonisrc.ts fix(drug-reference): backfill the missing dataset install row on boot 2026-09-29 15:54:41 -07:00
eslint.config.js feat: openwebui+ollama and zim management 2025-07-09 09:08:21 -07:00
package-lock.json chore(deps): restore dev's package-lock 2026-09-29 15:54:41 -07:00
package.json refactor(maps): curate the marker icon set, drop the tree view 2026-09-29 15:54:41 -07:00
tailwind.config.ts feat: initial commit 2025-06-29 15:51:08 -07:00
tsconfig.json Add offline FDA drug reference (labels, interaction view, conditions, remedies) (#1040) 2026-08-04 03:38:33 +00:00
vite.config.ts fix(Maps): ensure proper parsing of hostnames (#640) 2026-04-03 14:26:50 -07:00