Skip to content

fix(search): ignore invalid photo exposure times - #3420

Merged
dschmidt merged 2 commits into
opencloud-eu:mainfrom
fredrikblau:fix/3410-upload-file-date
Sep 1, 2026
Merged

fix(search): ignore invalid photo exposure times#3420
dschmidt merged 2 commits into
opencloud-eu:mainfrom
fredrikblau:fix/3410-upload-file-date

Conversation

@fredrikblau

Copy link
Copy Markdown

Summary

Apache Tika can report exif:ExposureTime as 0.0 for 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.go
  • go test ./services/search/pkg/content
  • git diff --check

Fixes #3267

@codacy-production

codacy-production Bot commented Aug 29, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 1 duplication

Metric Results
Duplication 1

View in Codacy

🟢 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

View coverage diff in Codacy

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.

@butonic

butonic commented Aug 31, 2026

Copy link
Copy Markdown
Member

@dschmidt can I get your review on this?

@dschmidt

Copy link
Copy Markdown
Contributor

Thanks, good catch!

One suggestion: I'd guard the computed denominator instead of the input and just skip the block instead of returning early. ExposureTime happens to be the last field today, but if someone adds another field below, the early return would silently drop it. Checking the result also covers the subnormal case where i > 0 but 1/i still overflows to +Inf:

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.

@dschmidt

dschmidt commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

I'm afraid my merge of #3198 caused a merge conflict here, can you rebase please? :)

@fredrikblau
fredrikblau force-pushed the fix/3410-upload-file-date branch from 0ba526d to 67124a6 Compare September 1, 2026 16:55
@fredrikblau

Copy link
Copy Markdown
Author

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.

@dschmidt dschmidt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! :)

@dschmidt
dschmidt enabled auto-merge September 1, 2026 17:13
@dschmidt
dschmidt merged commit cc73c95 into opencloud-eu:main Sep 1, 2026
66 of 67 checks passed
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.

json: unsupported value: +Inf when indexing files with embedded images that have ExposureTime=0

4 participants