Skip to content

fix(repo-finder): notes-only preferences fall back to defaults; overrides read '## filters'#30

Merged
gaurav0107 merged 3 commits into
mainfrom
fix/repo-finder-preferences-followups
Jul 19, 2026
Merged

fix(repo-finder): notes-only preferences fall back to defaults; overrides read '## filters'#30
gaurav0107 merged 3 commits into
mainfrom
fix/repo-finder-preferences-followups

Conversation

@gaurav0107

@gaurav0107 gaurav0107 commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Two follow-up fixes to the user-preferences feature in #29. Stacked on #29 — its commits ride along in this diff until it lands; once #29 is merged this collapses to a single commit. The files this PR owns are scripts/lib/preferences.sh, scripts/repo-finder/build_queries.sh, commands/repo-finder.md, CHANGELOG.md, and the two tests.

1. A preferences.md with no ## Filters block dead-ended the whole scan

A file carrying only ## Notes (advisory guidance, keep default filters) — or an empty ## Filters block — compiled to a catch-all, so build_queries.sh aborted repo-finder with exit 10 and:

FATAL: 'topics: any' with no languages is a catch-all — it matches every repo on GitHub.

…an error naming topics: any, which the user never wrote. Downstream, /contribute then hit an empty shortlist and told the user to run /repo-finder — a dead end for someone who just wanted to add notes on top of the default filters.

Fix: a file with no ## Filters content now means "default filters, plus advisory notes" and falls back to DEFAULT_PROFILE. A ## Filters block with content (even a typo'd key like langauges: go) still goes to the parser and fails loud — the fallback never swallows a malformed filter. Implemented with a new prefs_has_filters helper that reuses the single existing Filters-block reader (_prefs_filter_lines), so there's no third parser to drift.

2. /repo-finder overrides silently ignored a saved ## filters (lowercase) header

The override path (--lang/--topic/--min-stars) inherits the axes you don't name from your saved profile. It read that profile with an exact, case-sensitive ## Filters matcher, while scripts/lib/preferences.sh accepts ## filters and spacing variants. So on a hand-edited lowercase-header profile, /repo-finder --topic cli silently dropped the saved languages/stars and searched with defaults — the exact silent-wrong-result this feature exists to prevent.

Fix: the override path now detects the block with the same matcher preferences.sh uses.

Tests

  • tests/scripts/test_build_queries.sh — added the notes-only and empty-## Filters cases (both must fall back to the golden default profile); the existing malformed-abort case guards that a real typo still exits 10.
  • tests/scripts/test_repo_finder_override_inherit.sh (new) — an override on a lowercase ## filters profile must inherit the saved languages/stars.

Both were written test-first and watched fail before the fix. Full suite 64/64 green on local bash; network-free and bash-3.2-clean so they gate on ubuntu and macOS.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • /repo-finder now treats notes-only or empty ## Filters in preferences.md as “default filters + advisory notes,” avoiding failures and empty shortlists.
    • Saved-profile ## Filters headers are matched case-insensitively (and tolerate header/whitespace variations), so valid axes aren’t dropped.
    • Inherited overrides validate saved preferences and fail loudly on malformed filter keys.
  • Tests

    • Extended query fallback coverage (notes-only, empty filters, case-insensitive ## FILTERS).
    • Added network-free coverage for /repo-finder saved-profile override inheritance, including failure scenarios.

…ead '## filters' too

Two follow-up fixes to the user-preferences feature (#29):

- A preferences.md with no ## Filters content (only ## Notes, or an empty
  block) compiled to a catch-all and aborted repo-finder with exit 10 and a
  misleading "topics: any with no languages" error the user never wrote,
  leaving /contribute with an empty shortlist. It now falls back to
  DEFAULT_PROFILE ("default filters, plus advisory notes"). A ## Filters block
  with a real typo still fails loud, so the fallback never swallows a
  malformed filter. New prefs_has_filters helper in scripts/lib/preferences.sh.

- The /repo-finder override path (--lang/--topic/--min-stars) inherited saved
  axes with an exact, case-sensitive '## Filters' matcher while preferences.sh
  accepts '## filters' and spacing variants, so an override on a hand-edited
  lowercase-header profile silently dropped the saved languages/stars and
  searched with defaults. Both readers now use the same detector.

Tests: extend test_build_queries.sh (notes-only + empty-block cases), add
test_repo_finder_override_inherit.sh. Full suite 64/64 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ff36b68-4ebc-4f4b-86cb-0c91f706361c

📥 Commits

Reviewing files that changed from the base of the PR and between 2978094 and a9b2e52.

📒 Files selected for processing (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

repo-finder now treats missing or empty preference filters as default-profile input, recognizes non-canonical Filters headers during override inheritance, and validates inherited saved profiles before compilation.

Changes

Preferences filter handling

Layer / File(s) Summary
Filter presence and default fallback
scripts/lib/preferences.sh, scripts/repo-finder/build_queries.sh, tests/scripts/test_build_queries.sh, CHANGELOG.md
Adds filter-content detection, supports case-insensitive headers, falls back to DEFAULT_PROFILE for notes-only and empty-filter preferences, and tests the resulting query behavior.
Override filter inheritance
commands/repo-finder.md, tests/scripts/test_repo-finder_override_inherit.sh
Makes saved filter extraction tolerant of header variants, validates inherited malformed profiles, and tests partial and full override behavior.

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

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant Override as repo-finder override
  participant Preferences as preferences.sh
  participant Compiler as build_queries.sh
  Override->>Compiler: Validate inherited preferences
  Compiler->>Preferences: Detect and parse Filters
  Preferences-->>Compiler: Parsed filters or default fallback
  Compiler-->>Override: Compiled override query
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately captures the main repo-finder fixes: fallback on notes-only preferences and case-insensitive filter-header handling.
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
  • Commit unit tests in branch fix/repo-finder-preferences-followups

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: 2

🧹 Nitpick comments (1)
tests/scripts/test_repo_finder_override_inherit.sh (1)

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

Cover the full header-normalization contract.

This regression test exercises only ## filters. Add ## FILTERS, mixed-case, and whitespace variants so the test catches incomplete case-insensitive matching.

🤖 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 `@tests/scripts/test_repo_finder_override_inherit.sh` around lines 20 - 28,
Expand the saved-profile fixture in the test covering the override inheritance
path to include separate headers for ## FILTERS, mixed-case ## Filters, and
whitespace variants around the header. Keep the existing preference values and
assertions, ensuring each variant is processed identically by the header parser.
🤖 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 `@commands/repo-finder.md`:
- Around line 123-126: Update the saved-profile handling around the awk
extraction to validate the full non-empty $SAVED filter block with the canonical
parser before constructing the temporary override. Ensure malformed lines such
as misspelled axis keys are rejected explicitly rather than silently omitted,
and preserve normal extraction for valid saved filters.

In `@scripts/lib/preferences.sh`:
- Around line 58-60: Normalize the `## Filters` header case-insensitively in
both readers: update `_prefs_filter_lines` used by `prefs_has_filters` in
scripts/lib/preferences.sh at lines 58-60, and apply equivalent `tolower(...)`
normalization when inheriting saved axes for overrides in
commands/repo-finder.md at lines 119-122. Preserve the existing filtering and
override behavior.

---

Nitpick comments:
In `@tests/scripts/test_repo_finder_override_inherit.sh`:
- Around line 20-28: Expand the saved-profile fixture in the test covering the
override inheritance path to include separate headers for ## FILTERS, mixed-case
## Filters, and whitespace variants around the header. Keep the existing
preference values and assertions, ensuring each variant is processed identically
by the header parser.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f7c7dd6e-b368-48b9-9e58-bda8b9d0e8e5

📥 Commits

Reviewing files that changed from the base of the PR and between d54d054 and 70109e4.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • commands/repo-finder.md
  • scripts/lib/preferences.sh
  • scripts/repo-finder/build_queries.sh
  • tests/scripts/test_build_queries.sh
  • tests/scripts/test_repo_finder_override_inherit.sh

Comment thread commands/repo-finder.md
Comment thread scripts/lib/preferences.sh
…ile, full case-insensitive header

Two follow-ups from the PR #30 review:

- Validate the saved profile before inheriting axes in an override run. The
  override extraction greps the saved ## Filters block for exact keys, so a
  typo'd `langauges: go` (which the normal path rejects with exit 10) was
  silently dropped, letting `/repo-finder --topic cli` proceed on a broken
  profile. When any axis is inherited, $SAVED is now validated with the same
  compiler the normal path uses; a full --lang/--topic/--min-stars override
  skips the check (it reads nothing from the saved file).

- Match the ## Filters header fully case-insensitively (tolower) in both
  readers. Only `Filters`/`filters` were recognized before; a `## FILTERS`
  block was silently ignored, and with the notes-only fallback that emitted the
  default profile and dropped the user's filters with no error.

Tests: add the uppercase-header case to test_build_queries.sh; extend
test_repo_finder_override_inherit.sh with malformed-saved (must fail loud) and
full-override (must not be blocked) contracts. Full suite 64/64 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@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

🧹 Nitpick comments (1)
tests/scripts/test_repo_finder_override_inherit.sh (1)

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

Cover the uppercase header variant.

This only exercises ## filters; add ## FILTERS to protect the stated fully case-insensitive contract.

Proposed test addition
+SAVED_UC='## FILTERS
+languages: go
+topics: backend
+stars: 3000
+'
+OUT=$(run_override "$SAVED_UC" "" "cli" "") \
+  || fail "override on an uppercase Filters header errored: $OUT"
+case "$OUT" in *"languages: go"*"stars: 3000"*) ;; *)
+  fail "saved axes not inherited from '## FILTERS':
+$OUT" ;;
+esac
🤖 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 `@tests/scripts/test_repo_finder_override_inherit.sh` around lines 45 - 50,
Extend the Contract 1 test fixture in test_repo_finder_override_inherit.sh to
include an uppercase ## FILTERS header alongside the existing lowercase ##
filters case. Ensure the test verifies unnamed-axis inheritance remains
successful under the uppercase header, preserving the fully case-insensitive
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 `@CHANGELOG.md`:
- Line 22: Polish the changelog entry by replacing “fails loud” with “fails
loudly” (or “fails explicitly”) and “typo'd” with “mistyped,” leaving the
surrounding technical explanation unchanged.

---

Nitpick comments:
In `@tests/scripts/test_repo_finder_override_inherit.sh`:
- Around line 45-50: Extend the Contract 1 test fixture in
test_repo_finder_override_inherit.sh to include an uppercase ## FILTERS header
alongside the existing lowercase ## filters case. Ensure the test verifies
unnamed-axis inheritance remains successful under the uppercase header,
preserving the fully case-insensitive 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f274086-0116-4437-a753-a3d7bd2c16b3

📥 Commits

Reviewing files that changed from the base of the PR and between 70109e4 and 2978094.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • commands/repo-finder.md
  • scripts/lib/preferences.sh
  • tests/scripts/test_build_queries.sh
  • tests/scripts/test_repo_finder_override_inherit.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/scripts/test_build_queries.sh
  • scripts/lib/preferences.sh

Comment thread CHANGELOG.md Outdated
Address CodeRabbit nitpick on #30: use 'mistyped' over "typo'd" and
'fails loudly' over 'fails loud' in the two new Fixed entries.
@gaurav0107
gaurav0107 merged commit 818aaf7 into main Jul 19, 2026
3 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.

1 participant