Strict mimetypes or not?

Open
#163 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start in kobo/http.py at lines 32-40 and read how mimetypes.guess_type is called. Reproduce the containerized .rtf example with strict mode enabled and disabled, then decide which behavior the HTTP handling should use. Done means the chosen behavior is implemented and the .rtf case is verified without relying on /etc/mime.types.

Written by the indexing model from the issue text.

Description

We use mimetypes.guess_type in
https://github.com/release-engineering/kobo/blob/eaff9b42ed27e67ffe0338fdda6df19c948238dd/kobo/http.py#L32-L40
guess_type has strict option set to True by default which means that common_types included in Python stdlib are ignored.
For example, in a containerized environment without /etc/mime.types file, .rtf extension is not resolvable with strict mode turned on:

/usr/bin/python2.7
(None, None)
/usr/bin/python3.10
(None, None)
/usr/bin/python3.6
(None, None)
/usr/bin/python3.8
(None, None)
/usr/bin/python3.9
(None, None)

but without it, it works:

/usr/bin/python2.7
('application/rtf', None)
/usr/bin/python3.10
('application/rtf', None)
/usr/bin/python3.6
('application/rtf', None)
/usr/bin/python3.8
('application/rtf', None)
/usr/bin/python3.9
('application/rtf', None)

so turning off the strict mode might make it better for containerized environments and if we merge #162 we won't need mailcap package for tests (provides /etc/mime.types).

Dominant language
Python
Stars
16
Forks
38
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from release-engineering/kobo

All issues in release-engineering/kobo

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.