Skip to content

fix: remove unsupported HTML upload option from admin document picker - #215

Open
sandeep-2536 wants to merge 1 commit into
vicharanashala:mainfrom
sandeep-2536:fix/remove-unsupported-html-upload
Open

fix: remove unsupported HTML upload option from admin document picker#215
sandeep-2536 wants to merge 1 commit into
vicharanashala:mainfrom
sandeep-2536:fix/remove-unsupported-html-upload

Conversation

@sandeep-2536

Copy link
Copy Markdown

What was broken

The admin document-upload UI in AdminContextSources.tsx advertised HTML
(.html/.htm) as an accepted file type — in the file picker's accept
attribute, the upload subtitle text, and the error message — but the
backend has never supported it. The multer filter and controller validation
in admin-documents.routes.ts / adminDocuments.controller.ts only allow
PDF/TXT/Markdown/CSV, so any HTML upload was silently rejected with a 400.

Git blame confirms this wasn't accidental: the original commit's comment
explicitly says HTML support "will still be rejected by the backend until
ALLOWED_MIME... is extended (tracked as a TODO)" — planned follow-up work
that was never completed.

Fix

Removed HTML/HTM from the upload-specific UI only:

  • File input accept attribute (.pdf,.txt,.md,.csv,.html,.htm.pdf,.txt,.md,.csv)
  • Upload card subtitle text
  • Upload error message
  • The now-resolved TODO comment above the input

The separate "Paste text or HTML" feature (pasting raw text/HTML directly,
not file upload) is untouched — that's a different feature path with its
own handling and was intentionally left as-is.

Why this approach

Considered two options: (A) remove HTML from the frontend to match backend
reality, or (B) implement real backend HTML parsing/extraction. Went with
(A) because (B) would require new parsing logic, security hardening
(sanitization, since HTML is untrusted input), and test coverage — a
reasonable future feature, but not a fit for a bug-fix PR. (A) directly
closes the mismatch with no functional risk.

How this was found

Found via manual code review, not from an assigned GitHub issue.

Testing

  • Updated AdminContextSources.test.tsx to assert the file input's
    accept value is now .pdf,.txt,.md,.csv
  • Manually tested: .html/.htm no longer selectable in the file picker,
    subtitle/error text read correctly, PDF/TXT upload still works unchanged
  • pnpm exec tsc --noEmit — clean, no errors
  • pnpm testAdminContextSources.test.tsx passes (9/9). 3 unrelated
    test suites (api.test.ts, PremiumTee.test.ts,
    GoldenTicketDetailPage.test.tsx) fail on main as well, due to a
    pre-existing tooling error (jsTokens is not a function) unrelated to
    this change.

Frontend advertised HTML/HTM uploads that the backend has never
supported. Closes out the unfinished TODO from the original commit
rather than implementing backend HTML support.
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