Skip to content

docs(infer): clarify default no-op behaviour of content_type helpers#55

Merged
nao1215 merged 1 commit into
mainfrom
docs/issue-52-infer-default-noop-docs
May 20, 2026
Merged

docs(infer): clarify default no-op behaviour of content_type helpers#55
nao1215 merged 1 commit into
mainfrom
docs/issue-52-infer-default-noop-docs

Conversation

@nao1215

@nao1215 nao1215 commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

multipartkit/infer.content_type_from_filename and content_type_from_bytes are documented default no-ops of the pluggable inference interface — they always return None, even for well-known extensions like photo.png or 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 get None. 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 on content_type_from_filename and content_type_from_bytes to state that both helpers always return None for every input, explain that multipartkit deliberately ships no built-in inference, and show a worked example of wiring nao1215/mimetype into form.add_file_auto_with. Cross-reference examples/mimetype_inference.
  • README.md: extend the "Pluggable content-type inference" bullet so the top-level helpers' default-None policy 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 for content_type_from_filename (.png, .pdf, .js, .html, empty), for content_type_from_bytes (full PNG signature, JPEG SOI, %PDF-, empty), and for default_inferer() direct calls. Includes the exact infer_default_returns_none_test from the issue.
  • CHANGELOG.md: new ### Documentation entry 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/mimetype as a default inferer) was rejected because it would add a runtime dependency for what multipartkit explicitly designs as a pluggable seam, and it would couple multipartkit to one specific mime-detection library. Option C (delete the helpers) was rejected because the Inferer shape 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-None foot-gun. The runtime code is intentionally untouched so existing callers see no behaviour change.

Closes #52

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@nao1215 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9c81b16-a1b6-44ef-b7c8-844f0d73e45d

📥 Commits

Reviewing files that changed from the base of the PR and between b76922c and f6f574b.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • README.md
  • src/multipartkit/infer.gleam
  • test/regression_infer_default_test.gleam
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/issue-52-infer-default-noop-docs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nao1215 nao1215 merged commit 15ad7c8 into main May 20, 2026
5 checks passed
@nao1215 nao1215 deleted the docs/issue-52-infer-default-noop-docs branch May 20, 2026 14:14
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.

infer.content_type_from_filename/from_bytes are no-op defaults — silently return None for known types

1 participant