[19.0][FIX] dms: don't crash computing the extension of unknown mimetypes #551
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.18) × (1 − Review Confidence (0.74)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.18 · 8 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.49 · 4 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.131
Real PR Conversation Timeline
4 comments
dms/models/dms_file.py
"```suggestion
for record in self.filtered("content"):
```"
clarifying
weight: 0.45
dms/models/dms_file.py
"Done, thanks!"
clarifying
weight: 0.45
dms/tools/file.py
"So the changes to dms/tools.file.py aren't necessary after all, right?"
clarifying
weight: 0.45
dms/tools/file.py
"No, they're still needed: `filtered("content")` only skips records without content. A shell script named `deploy` has content, and its mimetype (`text/x-shellscript`) has no known extension in Python's `mimetypes`, so line 99 still raises the `TypeError`. I checked it: with only the model change, creating that file still fails.
"
clarifying
weight: 0.45
victoralmau
skanndar
Problem
With python-magic installed (as in the official odoo:19 image), creating a
dms.filewhose name has no extension fails when its content is detected as a mimetype that Python'smimetypesmodule doesn't know, e.g. a shell script nameddeploy(text/x-shellscript):TypeError: 'NoneType' object is not subscriptable
dms/tools/file.py, line 99, in guess_extension
Renaming such a file to a name without extension fails the same way. Other types in this case include Makefiles, RTF and Windows executables.
The crash is reachable since 96128e4, which started passing the mimetype and content to
guess_extension().Fix
tools/file.py:(mimetypes.guess_extension(mimetype) or "")[1:]in both places._compute_extensionpassedrecord.content(base64) toguess_extension(), which expects the binary, so its second guess was always made on base64 text (text/plain→txt). Decode it, for records with content only.The extension stays empty for such files.