[PR #99] [MERGED] fix(fal): upload local files through fal's CDN token route #123

Closed
opened 2026-10-15 20:53:35 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rehan-remade/universal-modder/pull/99
Author: @AltDoug
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/6/2026
Merged by: @rehan-remade

Base: main ← Head: fix/fal-upload-cdn-v3


📝 Commits (1)

  • da49b6d fix(fal): upload local files through fal's CDN token route

📊 Changes

2 files changed (+56 additions, -8 deletions)

View changed files

📝 tests/test_um.py (+36 -0)
📝 um/fal.py (+20 -8)

📄 Description

Every local-file input to um fal (@file.png, --ref, um fal upload) currently starts with:

um: fal POST https://rest.fal.ai/storage/upload/initiate -> HTTP 400: {"detail":"Invalid storage type"}

storage/upload/initiate?storage_type=gcs no longer accepts that storage type. Files under 8 MiB still work through the data-URI fallback, but the error line shows up in every log and looks like a failure. Files over 8 MiB re-raise and exit 1 with nothing after that 400, so a 9 MB video input just stops.

Fix: upload the way fal-client does now (its default "fal_v3" repository): POST rest.fal.ai/storage/auth/token?storage_type=fal-cdn-v3 for a short-lived token, then POST v3.fal.media/files/upload with the bytes, returning access_url. The data-URI fallback stays for small files, now with a one-line note. A big file that can't be uploaded now says why and names the 8 MiB limit instead of exiting silently. Files over ~100 MB would need fal's multipart route; that's not in this PR.

Tests: new test_upload_uses_cdn_token_and_explains_big_failures (fails before, passes after); full suite 59 passed on Windows 11, Python 3.12. Live against fal: a 2 KB and a 9,000,000 B file both upload with no 400, and the 9 MB one downloads back byte-identical (cmp).

Found and fixed with AI assistance (Claude Code); the repro and the fix were run by hand on Windows 11.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rehan-remade/universal-modder/pull/99 **Author:** [@AltDoug](https://github.com/AltDoug) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/6/2026 **Merged by:** [@rehan-remade](https://github.com/rehan-remade) **Base:** `main` ← **Head:** `fix/fal-upload-cdn-v3` --- ### 📝 Commits (1) - [`da49b6d`](https://github.com/rehan-remade/universal-modder/commit/da49b6d4302e28d94b2bf8a02fa31ae8a45eda46) fix(fal): upload local files through fal's CDN token route ### 📊 Changes **2 files changed** (+56 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_um.py` (+36 -0) 📝 `um/fal.py` (+20 -8) </details> ### 📄 Description Every local-file input to `um fal` (`@file.png`, `--ref`, `um fal upload`) currently starts with: ``` um: fal POST https://rest.fal.ai/storage/upload/initiate -> HTTP 400: {"detail":"Invalid storage type"} ``` `storage/upload/initiate?storage_type=gcs` no longer accepts that storage type. Files under 8 MiB still work through the data-URI fallback, but the error line shows up in every log and looks like a failure. Files over 8 MiB re-raise and exit 1 with nothing after that 400, so a 9 MB video input just stops. Fix: upload the way fal-client does now (its default "fal_v3" repository): `POST rest.fal.ai/storage/auth/token?storage_type=fal-cdn-v3` for a short-lived token, then `POST v3.fal.media/files/upload` with the bytes, returning `access_url`. The data-URI fallback stays for small files, now with a one-line note. A big file that can't be uploaded now says why and names the 8 MiB limit instead of exiting silently. Files over ~100 MB would need fal's multipart route; that's not in this PR. Tests: new `test_upload_uses_cdn_token_and_explains_big_failures` (fails before, passes after); full suite 59 passed on Windows 11, Python 3.12. Live against fal: a 2 KB and a 9,000,000 B file both upload with no 400, and the 9 MB one downloads back byte-identical (`cmp`). Found and fixed with AI assistance (Claude Code); the repro and the fix were run by hand on Windows 11. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 20:53:35 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rehan-remade/universal-modder#123
No description provided.