docs(infer): clarify default no-op behaviour of content_type helpers#55
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
multipartkit/infer.content_type_from_filenameandcontent_type_from_bytesare documented default no-ops of the pluggable inference interface — they always returnNone, even for well-known extensions likephoto.pngor magic-byte signatures like the PNG header. The original docstrings under-sold this contract, so a caller could reasonably expect built-in sniffing and silently getNone. This PR clarifies the contract in the docstring, in the README, and pins the behaviour with regression tests, without touching the runtime behaviour.Changes
src/multipartkit/infer.gleam: expand the docstrings oncontent_type_from_filenameandcontent_type_from_bytesto state that both helpers always returnNonefor every input, explain that multipartkit deliberately ships no built-in inference, and show a worked example of wiringnao1215/mimetypeintoform.add_file_auto_with. Cross-referenceexamples/mimetype_inference.README.md: extend the "Pluggable content-type inference" bullet so the top-level helpers' default-Nonepolicy is visible from the front door, and link the runnable example.test/regression_infer_default_test.gleam: new regression file pinning the no-op behaviour forcontent_type_from_filename(.png,.pdf,.js,.html, empty), forcontent_type_from_bytes(full PNG signature, JPEG SOI,%PDF-, empty), and fordefault_inferer()direct calls. Includes the exactinfer_default_returns_none_testfrom the issue.CHANGELOG.md: new### Documentationentry under## [Unreleased]recording the doc clarification (infer.content_type_from_filename/from_bytes are no-op defaults — silently return None for known types #52).Design Decisions
Adopted issue option A (docstring + README clarification, no behavioural change). Option B (bundle
nao1215/mimetypeas a default inferer) was rejected because it would add a runtime dependency for what multipartkit explicitly designs as a pluggable seam, and it would couplemultipartkitto one specific mime-detection library. Option C (delete the helpers) was rejected because theInferershape itself is part of the public surface and keeping symmetric top-level accessors is more discoverable than removing them; the doc clarification is sufficient to remove the silent-Nonefoot-gun. The runtime code is intentionally untouched so existing callers see no behaviour change.Closes #52