fix(search): ignore invalid photo exposure times - #3420
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 1 |
🟢 Coverage 100.00% diff coverage · +0.00% coverage variation
Metric Results Coverage variation ✅ +0.00% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (f60e2e5) 87708 20427 23.29% Head commit (67124a6) 87709 (+1) 20430 (+3) 23.29% (+0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#3420) 6 6 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
@dschmidt can I get your review on this? |
|
Thanks, good catch! One suggestion: I'd guard the computed denominator instead of the input and just skip the block instead of returning early. if v, err := getFirstValue(meta, "exif:ExposureTime"); err == nil {
if i, err := strconv.ParseFloat(v, 64); err == nil {
if d := math.Round(1 / i); !math.IsNaN(d) && !math.IsInf(d, 0) && d > 0 {
initPhoto()
photo.SetExposureNumerator(1)
photo.SetExposureDenominator(d)
}
}
}That's one check for all the broken inputs (0, negative, NaN, subnormal) and no early return. Otherwise looks good to me. |
|
I'm afraid my merge of #3198 caused a merge conflict here, can you rebase please? :) |
0ba526d to
67124a6
Compare
|
Rebased onto current main and resolved the conflict. The exposure-denominator guard and regression test are preserved. go test ./services/search/pkg/content and git diff --check pass locally. |
Summary
Apache Tika can report
exif:ExposureTimeas0.0for embedded placeholder images. Dividing by that value creates+Inf, which later makes the Graph photo JSON impossible to marshal and prevents the containing file from being indexed.Ignore non-positive and non-finite exposure values while preserving valid photo metadata.
Testing
gofmt -w services/search/pkg/content/tika.go services/search/pkg/content/tika_test.gogo test ./services/search/pkg/contentgit diff --checkFixes #3267