Skip to content

fixed anyinput formats being unreachable#480

Open
neko782 wants to merge 3 commits intop2r3:masterfrom
neko782:fix-anyinput
Open

fixed anyinput formats being unreachable#480
neko782 wants to merge 3 commits intop2r3:masterfrom
neko782:fix-anyinput

Conversation

@neko782
Copy link
Contributor

@neko782 neko782 commented Mar 2, 2026

fixing a bug i found when making my tar pr: anyInput handlers did not work at all. (if you convert anything like a png or a text file to a zip or lzh, it always goes through docx and html instead of direct conversion)

the second loop is needed because we need to construct all anyinput paths after all the normal paths are done in order to prioritize nonanyinput paths.

the only issue rn is that anyinput is all or nothing rn - so something like lzh tries to convert anything we try to convert to zip (as it declares that it can accept "any input" and that it produces a zip file as a result) and obviously fails with a (harmless) console error. thatd need deeper changes though, so i left it like that and even with that it works perfectly fine.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@neko782
Copy link
Contributor Author

neko782 commented Mar 2, 2026

found an issue: when converting a renamezip to another archive (ex. tar or lza), it chooses sb3 -> tar instead of sb3 -> zip -> tar which is obviously not the intended behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@neko782
Copy link
Contributor Author

neko782 commented Mar 2, 2026

added a penalty to the anyinput formats. right now this works great - sb3 chooses sb3 -> zip -> lza and html doesnt choose something like html -> docs -> zip (which is bad imo, better to just pack it which will make more sense to the user and preserves data better), but if we were to add other non-packing anyinput formats it could cause issues. lmk if thats an issue

@p2r3
Copy link
Owner

p2r3 commented Mar 3, 2026

it chooses sb3 -> tar instead of sb3 -> zip -> tar which is obviously not the intended behavior

No, it's really not obvious why that's not intended behavior. That's the shorter route, and all the first step does is rename the file anyway. This should be fixed by adjusting your handler, not messing with weights.

I don't really know what to do about this all being vibecoded either, I'll leave that decision for tomorrow.

@neko782
Copy link
Contributor Author

neko782 commented Mar 3, 2026

my handler is fine, it compresses anything you give it (just like jszip's handler does)

sb3 -> tar means that it just takes the sb3 file and puts it inside of a tar archive (is that really useful?) instead of interpreting the sb3 as zip which makes for a conversion that makes more sense

messing with the weights was potentially kinda a bad option though (it may introduce path regressions) so i can undo it

@p2r3
Copy link
Owner

p2r3 commented Mar 3, 2026

Ah, right. I forgot that the rename handler changes the MIME type too.

After properly looking over the code now, I do see merit in de-prioritizing anyInput edges. Though your specific scenario with archives seems like a slightly different issue. To me, it seems like an archive handler should be able to recognize that its input is an archive, regardless of if it's been renamed or if the MIME type has been changed.

One solution I see is to add CommonFormats' Category.ARCHIVE to these files? Currently that's only on ZIP as far as I can tell, but I think it makes sense to have it on all of the ZIP-like stuff, including most stuff in the rename handler. Though that doesn't really tell you what kind of archive the input is...

@p2r3
Copy link
Owner

p2r3 commented Mar 3, 2026

Also, this fails to build. Check with bun run build.

@neko782
Copy link
Contributor Author

neko782 commented Mar 3, 2026

Also, this fails to build. Check with bun run build.

aargh sorry im stupid!!!!!!!!!!!!!!! fixed now

@neko782
Copy link
Contributor Author

neko782 commented Mar 3, 2026

To me, it seems like an archive handler should be able to recognize that its input is an archive, regardless of if it's been renamed or if the MIME type has been changed.

i mean that would be nice but imagine if in the future we have some format that is .tar renamed, and then for other archive handlers to handle that properly (ex. lzh and zip) they would have to implement unpacking tars which is absolutely outside of the scope for that handler.

honestly i think having zip as a intermediate format that all other archive handlers understand is better, but i can implement detection of specifically just zip-likes in both tar and lzh

Currently that's only on ZIP as far as I can tell

theres a ton of formats that use category archive but dont use the Category enum - search "archive" in the repo. (ex .wad, .ic, .lzh... mine too) i mean the example does say that categories are specified as a string?

@neko782
Copy link
Contributor Author

neko782 commented Mar 4, 2026

@p2r3 this can be merged unless you want me to remove anyinput cost

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.

2 participants