Skip to content

feat(mediainfo): add General rule blocking files without video/audio track in mediainfo#229

Open
wasserrutschentester wants to merge 1 commit into
autobrr:mainfrom
wasserrutschentester:feat/no-tracks-warning
Open

feat(mediainfo): add General rule blocking files without video/audio track in mediainfo#229
wasserrutschentester wants to merge 1 commit into
autobrr:mainfrom
wasserrutschentester:feat/no-tracks-warning

Conversation

@wasserrutschentester

@wasserrutschentester wasserrutschentester commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

this could happen due to actually broken files or go-mediainfo being unstable autobrr/go-mediainfo#16

additionally broken tracker rules are now displayed in the cli

Summary by CodeRabbit

  • New Features
    • Metadata previews now show only the rule failures relevant to the selected upload trackers, making failure messages easier to read.
  • Bug Fixes
    • MediaInfo tracks are now marked invalid when no audio or video tracks are found, helping catch incomplete media data earlier.
    • Rule checks now report missing MediaInfo tracks as a validation failure.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a ValidMediaInfoTracks boolean field to PreparedMetadata, populated during media detail extraction when video/audio tracks are missing (excluding BDMV). EvaluateRules now flags this as a failure. Interactive CLI preview filters and displays rule failures by candidate trackers. Test literals updated accordingly.

Changes

ValidMediaInfoTracks flag and tracker-filtered rule failures

Layer / File(s) Summary
PreparedMetadata field and population
pkg/api/services.go, internal/metadata/media_details.go
Adds ValidMediaInfoTracks field to PreparedMetadata and sets it to false when no video/audio tracks are parsed (excluding BDMV, only when MediaInfo JSON path is set).
Rule evaluation gate for invalid tracks
internal/trackers/rules.go, internal/trackers/rules_test.go
EvaluateRules appends an invalid_mediainfo_tracks failure when the flag is false; extensive test literal updates add ValidMediaInfoTracks: true and new helper functions (hasMISettingsFailure, findRuleFailure, hasRuleFailure) across tracker rule tests.
Media details tests updated for ValidMediaInfoTracks
internal/metadata/media_details_test.go
Updates PreparedMetadata literals across edition, HDR, source/type, UHD, audio, and refresh tests to explicitly set ValidMediaInfoTracks: true.
Interactive CLI tracker-filtered rule failure display
cmd/upbrr/interactive.go, cmd/upbrr/cli_options_test.go
printMetadataPreview accepts a tracker list, filters TrackerRuleFailures case-insensitively, and prints a sorted Rule Failures section; interactive loop resolves and passes candidate trackers; test call updated for the new signature.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • autobrr/upbrr#148: Both PRs modify EvaluateRules to emit earlier MediaInfo-related rule failures.
  • autobrr/upbrr#157: Both PRs add new rule-failure types to EvaluateRules that flow into the same rule-failure pipeline.
  • autobrr/upbrr#187: Both PRs touch the printMetadataPreview call/signature and CLI rendering path.

Suggested reviewers: Audionut

Poem

A track was missing, video and sound,
so the rabbit flagged it, safe and sound.
Now trackers whisper their rule complaints,
filtered and sorted, no more restraints.
Hop, hop, review — the fields align! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a mediainfo rule that blocks files missing video or audio tracks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
internal/trackers/rules_test.go (1)

544-575: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add coverage for the AZ-family gate gap.

TestEvaluateRulesModifiedReleaseAcrossFamilies covers PHD for modified_release but no test exercises invalid_mediainfo_tracks for AZ/CZ/PHD, which is why the bypass in rules.go (Lines 55-63) went unnoticed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/trackers/rules_test.go` around lines 544 - 575, Add test coverage
for the AZ-family gate gap by extending
TestEvaluateRulesModifiedReleaseAcrossFamilies or adding a new focused test that
exercises invalid_mediainfo_tracks for AZ/CZ/PHD. Use EvaluateRules and the
existing rule-finding helpers to assert that trackers in the AZ family do not
bypass invalid_mediainfo_tracks when ValidMediaInfoTracks is false, and that the
failure is present for the relevant tracker family cases. Keep the test
structure parallel-friendly and refer to the tracker family names directly so
the bypass in rules.go is covered.
internal/trackers/rules.go (1)

55-63: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

AZ/CZ/PHD trackers bypass the new invalid_mediainfo_tracks gate.

The switch at Line 56 returns early (return append(failures, evaluateAZFamilyRules(...)...)) before the ValidMediaInfoTracks check at Lines 60-62 is ever reached. As a result, AZ-family trackers (AZ, CZ, PHD) never get flagged for missing video/audio tracks, unlike every other tracker family. This mirrors the existing modified_release check pattern (Lines 45-53), which is deliberately evaluated before the family switch specifically to apply universally — the new gate should follow the same pattern.

🐛 Proposed fix: move the gate before the family switch
 	if !skipsModifiedReleaseCheck(name) {
 		if renamed, reason := isRenamedRelease(meta); renamed {
 			addFailure("modified_release", reason)
 		}
 	}
+
+	if !meta.ValidMediaInfoTracks {
+		addFailure("invalid_mediainfo_tracks", "missing video or audio tracks in MediaInfo")
+	}
 
 	switch name {
 	case "AZ", "CZ", "PHD":
 		return append(failures, evaluateAZFamilyRules(name, meta)...)
 	}
 	rules, ok := additional.RulesFor(name)
-	if !meta.ValidMediaInfoTracks {
-		addFailure("invalid_mediainfo_tracks", "missing video or audio tracks in MediaInfo")
-	}
 
 	// UNIT3D-known trackers without a tracker-specific RuleSet must still reach
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/trackers/rules.go` around lines 55 - 63, The AZ/CZ/PHD family in
rules.go is returning early from the family switch before the new
invalid_mediainfo_tracks gate can run, so those trackers skip the MediaInfo
track validation. Move the ValidMediaInfoTracks check so it is evaluated before
the switch in the same way as the existing modified_release gate, and keep the
family-specific logic in evaluateAZFamilyRules and additional.RulesFor
unchanged. Ensure the added failure is applied universally before any early
return from the AZ/CZ/PHD branch.
🧹 Nitpick comments (1)
cmd/upbrr/interactive.go (1)

1154-1154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add test coverage for the new tracker-filtered Rule Failures output.

The filter/sort/print logic for Rule Failures (Lines 1179-1201) is new and not exercised by any test — TestPrintMetadataPreviewShowsRichReleaseDetails passes nil for trackers and never sets TrackerRuleFailures. Consider adding a case that verifies filtering (only candidate trackers shown), sorting, and formatting.

Also applies to: 1178-1201

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/upbrr/interactive.go` at line 1154, Add test coverage for the new
tracker-filtered Rule Failures path in printMetadataPreview, since the current
TestPrintMetadataPreviewShowsRichReleaseDetails never exercises it. Add a
focused case that passes trackers and populates TrackerRuleFailures so you can
verify the filtering keeps only matching candidate trackers, the output is
sorted as intended, and the printed formatting matches the new Rule Failures
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/metadata/media_details.go`:
- Around line 61-66: The MediaInfo validity check is incorrectly marking DVD
releases as invalid when MediaInfoJSONPath has no video/audio tracks, even
though DVDs are handled by a separate VOB MediaInfo path. Update the
ValidMediaInfoTracks logic in media details processing so the false case only
applies when the release is not BDMV and not DVD, using the existing DiscType
check alongside splitMediaInfoTracks and MediaInfoJSONPath to exempt DVDs from
triggering invalid_mediainfo_tracks.

---

Outside diff comments:
In `@internal/trackers/rules_test.go`:
- Around line 544-575: Add test coverage for the AZ-family gate gap by extending
TestEvaluateRulesModifiedReleaseAcrossFamilies or adding a new focused test that
exercises invalid_mediainfo_tracks for AZ/CZ/PHD. Use EvaluateRules and the
existing rule-finding helpers to assert that trackers in the AZ family do not
bypass invalid_mediainfo_tracks when ValidMediaInfoTracks is false, and that the
failure is present for the relevant tracker family cases. Keep the test
structure parallel-friendly and refer to the tracker family names directly so
the bypass in rules.go is covered.

In `@internal/trackers/rules.go`:
- Around line 55-63: The AZ/CZ/PHD family in rules.go is returning early from
the family switch before the new invalid_mediainfo_tracks gate can run, so those
trackers skip the MediaInfo track validation. Move the ValidMediaInfoTracks
check so it is evaluated before the switch in the same way as the existing
modified_release gate, and keep the family-specific logic in
evaluateAZFamilyRules and additional.RulesFor unchanged. Ensure the added
failure is applied universally before any early return from the AZ/CZ/PHD
branch.

---

Nitpick comments:
In `@cmd/upbrr/interactive.go`:
- Line 1154: Add test coverage for the new tracker-filtered Rule Failures path
in printMetadataPreview, since the current
TestPrintMetadataPreviewShowsRichReleaseDetails never exercises it. Add a
focused case that passes trackers and populates TrackerRuleFailures so you can
verify the filtering keeps only matching candidate trackers, the output is
sorted as intended, and the printed formatting matches the new Rule Failures
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: af0dc0a4-ffcf-4981-8e05-e387eaa47770

📥 Commits

Reviewing files that changed from the base of the PR and between 052d60c and 85be8b6.

📒 Files selected for processing (7)
  • cmd/upbrr/cli_options_test.go
  • cmd/upbrr/interactive.go
  • internal/metadata/media_details.go
  • internal/metadata/media_details_test.go
  • internal/trackers/rules.go
  • internal/trackers/rules_test.go
  • pkg/api/services.go

Comment thread internal/metadata/media_details.go
@Audionut

Copy link
Copy Markdown
Contributor

Finding: AZ-family trackers bypass the new MediaInfo-track gate

EvaluateRules returns early for AZ, CZ, and PHD before ValidMediaInfoTracks is checked. Consequently, invalid_mediainfo_tracks is not produced for those trackers, even though this is intended as a general blocking rule. The validation must run before any family-specific return.

Changes needed after #273 is merged

This should be reimplemented against #273 rather than rebased mechanically:

  • Do not restore ValidMediaInfoTracks on PreparedMetadata; refactor!: replace Wails with canonical embedded WebUI architecture #273 replaces those booleans with canonical ReleaseAssessments carried through UploadSubject and RuleSubject.
  • Record the source-derived track evidence in internal/preparedrelease/state.State while ApplyMediaDetails processes the MediaInfo document, then project it from State.ReleaseAssessments() using a typed present/missing/not-applicable status.
  • Add the strict invalid_mediainfo_tracks failure in internal/trackers/rules.go before registry lookup/unknown-tracker returns so it applies to every tracker family. refactor!: replace Wails with canonical embedded WebUI architecture #273 removes the AZ-family early-return path, but placement should still preserve the universal-rule contract.
  • The printMetadataPreview(..., trackers) change does not need to be ported. refactor!: replace Wails with canonical embedded WebUI architecture #273 already prints and enforces tracker failures through promptTrackerRuleReview, including strict disablement before auth and dupe work.
  • Add focused coverage for missing tracks, applicable/not-applicable assessment projection, universal tracker-family enforcement, and the existing CLI rule-review output.

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.

2 participants