Skip to content

Conversation

@digitalghost-dev
Copy link
Owner

@digitalghost-dev digitalghost-dev commented Jan 13, 2026

Summary by CodeRabbit

  • New Features

    • Regulation mark added to card displays.
    • Search enhanced with regex, fuzzy, and substring matching.
  • Bug Fixes / Data

    • Card listings now exclude non-numeric local IDs.
  • Documentation

    • Updated CLI help formatting, run examples, badges, and architecture diagram reference.
  • Tests

    • Expanded search unit tests for regex, fuzzy, and edge cases.
  • Chores

    • Bumped release/version strings, pinned select dependencies, and added .ai to .gitignore.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Version bumped v1.8.5 → v1.8.6 across release tooling and docs; dbt model/view and CLI extended to propagate a new regulation_mark field; search parsing upgraded to support regex and fuzzy matching; dependency pins and small test/CLI presentation tweaks applied.

Changes

Cohort / File(s) Summary
Version & release metadata
.github/workflows/ci.yml, .goreleaser.yml, Dockerfile, nfpm.yaml, README.md, testdata/main_latest_flag.golden
Bumped release/version strings from v1.8.5v1.8.6 (CI env, ldflags, packaging metadata, README badges/examples, golden text).
dbt config & view
card_data/pipelines/poke_cli_dbt/dbt_project.yml, card_data/pipelines/poke_cli_dbt/macros/create_view.sql, card_data/pipelines/poke_cli_dbt/models/cards.sql
Added materialized: table in dbt_project.yml; removed an on-run-end hook; extended model and public.card_pricing_view to include regulation_mark; added numeric localId filter.
API → CLI regulation propagation
cmd/card/cardlist.go, cmd/card/cardlist_test.go, cmd/card/setslist_test.go
Added RegulationMark to card data and RegulationMarkMap to CardsModel; API selection updated to include regulation_mark; tests refactored to use testSupabaseKey.
Search improvements
cmd/search/parse.go, cmd/search/parse_test.go, go.mod
Replaced simple substring search with regex parsing, fuzzy matching via closestmatch, and substring fallback; added helper functions (containsRegexChars, parseRegex, parseFuzzy, parseContains) and expanded tests; added indirect dependency github.com/schollz/closestmatch.
CLI presentation & small error-handling tweak
cli.go, cmd/ability/ability.go, testdata/cli_help.golden, testdata/cli_incorrect_command.golden
Centralized command rendering (commandDescriptions, renderCommandList), adjusted help formatting/golden files, and changed one error path to use utils.HandleFlagError().
Python deps pinning
card_data/pyproject.toml
Pinned dagster-postgres and dagster-webserver to exact versions in both main and dev dependency sections.
Docs / assets
card_data/README.md
Replaced external diagram URL with a local image filename (data_infrastructure_v2.png).
Misc git
.gitignore
Added rule to ignore /.ai/.

Sequence Diagram(s)

sequenceDiagram
  actor CLI
  participant API
  participant DBT as "dbt model / DB"
  participant View
  CLI->>API: Request card list
  API-->>CLI: Returns rows including regulation_mark
  Note over DBT,View: dbt materializes regulation_mark into model/table
  DBT->>View: Populate/refresh model with regulation_mark
  CLI->>View: Query view or render API data including regulation_mark
  View-->>CLI: Returns rows with regulation_mark for display
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • 1.8.2 #217: Overlapping edits to dbt view/model and cardlist field additions (regulation_mark) — likely directly related.
  • 1.7.4 #200: Similar version bump and release metadata changes affecting CI/goreleaser/Docker and dbt_project.yml.
  • 1.8.4 #224: Related release/versioning edits and same dbt_project.yml materialized-hook changes.

Poem

🐰 A hop to v1.8.6 I go,
New marks in rows begin to show,
Regex noses twitch and find,
Fuzzy friends fall in line,
I nibble bytes and watch them grow.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title '1.8.6' is generic and vague, using only a version number without describing what the PR accomplishes or changes. Use a descriptive title that explains the main change, such as 'Bump version to 1.8.6 and add regulation_mark to card data' or 'Release v1.8.6 with card pricing view enhancements'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
cmd/search/parse.go (3)

25-27: Consider user intent for common punctuation.

A literal search like mr.mime will be interpreted as regex (. matches any char), potentially returning unexpected results. If this is intentional, consider documenting this behavior to users. Otherwise, you might want to require an explicit flag or escape sequence for regex mode.


29-42: Consider ReDoS mitigation for user-supplied regex.

User-provided regex patterns could potentially cause catastrophic backtracking (ReDoS). While Pokemon names are short strings mitigating the risk, you might consider adding a timeout or using a regex engine with linear-time guarantees for defense-in-depth.

Minor optimization: pre-allocate the slice with capacity estimate.

♻️ Optional pre-allocation
-	filtered := make([]Result, 0)
+	filtered := make([]Result, 0, len(results)/4) // rough estimate

44-67: LGTM with a minor suggestion.

The fuzzy matching implementation is well-structured: builds an index, retrieves top matches, and preserves original ordering. Consider extracting the magic number 10 to a named constant for clarity.


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b64c139 and 3e5e4a5.

📒 Files selected for processing (2)
  • cmd/search/parse.go
  • cmd/search/parse_test.go
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/search/parse.go (1)
connections/connection.go (2)
  • ApiCallSetup (44-80)
  • APIURL (17-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: benchmarks
🔇 Additional comments (8)
cmd/search/parse.go (4)

3-10: LGTM on imports.

The new imports align with the added functionality: fmt for error wrapping, regexp for regex parsing, and closestmatch for fuzzy matching.


69-82: LGTM!

Clean implementation of case-insensitive substring matching with proper whitespace trimming and empty string handling.


84-98: Verify intended behavior when regex matches nothing.

If a search contains regex characters but the regex matches zero results (e.g., ^xyz), the function returns an empty list rather than falling back to contains/fuzzy. This may be intentional (explicit regex = no fallback), but verify this matches expected UX.


102-114: LGTM!

Proper error propagation from parseSearch with clean early return on failure.

cmd/search/parse_test.go (4)

6-33: LGTM!

Good expansion of test data and proper validation that substring matching takes precedence over fuzzy.


35-64: LGTM!

Excellent coverage of edge cases: whitespace trimming, case insensitivity, and fuzzy matching with intentional misspelling.


66-178: LGTM!

Comprehensive regex test coverage including prefix, suffix, character classes, alternation, quantifiers, and error handling for invalid patterns.


197-211: LGTM!

Good integration test demonstrating regex-based filtering through the query function.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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 and usage tips.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 13, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing 1.8.6 (3e5e4a5) with main (9db1ae1)

Summary

✅ 4 untouched benchmarks

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 84.12698% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/search/parse.go 86.95% 3 Missing and 3 partials ⚠️
cmd/card/cardlist.go 66.66% 1 Missing and 2 partials ⚠️
cmd/ability/ability.go 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
cli.go 87.12% <100.00%> (-1.47%) ⬇️
cmd/ability/ability.go 75.86% <0.00%> (+1.28%) ⬆️
cmd/card/cardlist.go 88.39% <66.66%> (-2.09%) ⬇️
cmd/search/parse.go 84.90% <86.95%> (+1.57%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @card_data/pyproject.toml:
- Around line 13-14: The dev dependency-group currently allows different
versions (e.g., dagster-postgres>=0.27.3 and dagster-webserver unconstrained)
which can diverge from the pinned production deps; update the dev group to pin
the same exact versions as the main dependencies by changing dagster-postgres to
dagster-postgres==0.28.7 and dagster-webserver to dagster-webserver==1.12.7 in
the dev dependency-group so dev and production installs are consistent.

In @cmd/ability/ability.go:
- Around line 100-105: The code writes the same error twice: remove the
redundant output.WriteString call inside the block that calls
flags.PokemonAbilitiesFlag so only utils.HandleFlagError(&output, err) writes
the error; update the branch that checks *af.Pokemon || *af.ShortPokemon (the
call to flags.PokemonAbilitiesFlag and subsequent error handling) by deleting
the output.WriteString(fmt.Sprintf("error parsing flags: %v\n", err)) line and
keeping the existing return utils.HandleFlagError(&output, err) to avoid
duplicate messages.

In @testdata/main_latest_flag.golden:
- Line 5: Update the golden test output in testdata/main_latest_flag.golden to
match the bumped version: replace the current displayed version string "v1.8.5"
with "v1.8.6" so the CLI --latest flag golden matches other files in the PR and
expected test output.
🧹 Nitpick comments (4)
cmd/search/parse_test.go (1)

19-131: Comprehensive regex test coverage.

The subtests thoroughly cover regex scenarios: anchors (^, $), character classes, alternation, quantifiers (+, ?), and error handling for invalid patterns.

One consideration: these tests implicitly assert that parseSearch preserves the input order of matching results. If this is intentional behavior, consider adding a brief comment documenting this contract. If order isn't guaranteed by the implementation, the assertions checking filtered[i].Name != expected[i] could become flaky.

cmd/card/cardlist.go (1)

164-170: Minor formatting inconsistency.

Line 168 has extra whitespace before regulationMarkMap. While not a functional issue, consider aligning with the other field assignments for consistency.

🔧 Suggested fix
 	return CardsModel{
 		IllustratorMap: illustratorMap,
 		ImageMap:       imageMap,
 		PriceMap:       priceMap,
-		RegulationMarkMap:  regulationMarkMap,
+		RegulationMarkMap: regulationMarkMap,
 		Table:          t,
 	}, nil
cmd/search/parse.go (2)

25-27: Regex detection may cause unexpected behavior for common search terms.

The heuristic triggers regex mode for any query containing characters like ., *, +, ?, etc. A user searching for "mr. mime" or "farfetch'd" (if apostrophe were listed) would unintentionally trigger regex mode. The period (.) is especially common in names but also a regex wildcard.

Consider either:

  1. Requiring an explicit prefix/flag for regex mode (e.g., r/pattern)
  2. Escaping special characters when not in regex mode
  3. Documenting this behavior clearly for users

60-66: Slice reuse mutates the original backing array.

filtered := results[:0] creates a slice that shares the same backing array as results. Appending to filtered overwrites elements in the original array. While this works in the current call site because result.Results is reassigned, it's error-prone if the code is refactored or if results is used elsewhere concurrently.

🔧 Safer approach: allocate a new slice
-	filtered := results[:0]
+	filtered := make([]Result, 0, len(matches))
 	for _, r := range results {
 		if _, ok := matchSet[r.Name]; ok {
 			filtered = append(filtered, r)
 		}
 	}
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9db1ae1 and c74aefa.

⛔ Files ignored due to path filters (3)
  • card_data/data_infrastructure_v2.png is excluded by !**/*.png
  • card_data/uv.lock is excluded by !**/*.lock
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (21)
  • .github/workflows/ci.yml
  • .goreleaser.yml
  • Dockerfile
  • README.md
  • card_data/README.md
  • card_data/pipelines/poke_cli_dbt/dbt_project.yml
  • card_data/pipelines/poke_cli_dbt/macros/create_view.sql
  • card_data/pipelines/poke_cli_dbt/models/cards.sql
  • card_data/pyproject.toml
  • cli.go
  • cmd/ability/ability.go
  • cmd/card/cardlist.go
  • cmd/card/cardlist_test.go
  • cmd/card/setslist_test.go
  • cmd/search/parse.go
  • cmd/search/parse_test.go
  • go.mod
  • nfpm.yaml
  • testdata/cli_help.golden
  • testdata/cli_incorrect_command.golden
  • testdata/main_latest_flag.golden
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/ability/ability.go (1)
cmd/utils/output.go (1)
  • HandleFlagError (24-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: benchmarks
🔇 Additional comments (28)
cli.go (3)

27-49: Clean refactor for command list rendering.

The introduction of commandDescriptions and renderCommandList() effectively centralizes command metadata and eliminates duplication. Using strings.Builder is the idiomatic and efficient approach for string concatenation in Go.


96-97: LGTM!

The integration of renderCommandList() into the help message maintains a single source of truth for command descriptions.


164-177: LGTM!

The error handling for invalid commands now uses the same renderCommandList() function, ensuring users see consistent command information whether viewing help or encountering errors.

testdata/cli_help.golden (1)

1-32: Golden file correctly reflects the refactored help output.

The command list and formatting align with the commandDescriptions data structure and renderCommandList() function in cli.go.

testdata/cli_incorrect_command.golden (1)

1-18: Golden file correctly reflects the refactored error output.

The error message format and command list are consistent with both cli.go and cli_help.golden, demonstrating the benefit of the renderCommandList() refactor for maintaining consistency.

Dockerfile (1)

11-11: LGTM!

Version bump to v1.8.6 is consistent with the PR objective. The Dockerfile maintains good security practices with multi-stage builds and non-root user execution.

card_data/pipelines/poke_cli_dbt/dbt_project.yml (2)

2-2: LGTM!

Version bump to 1.8.6 aligns with the broader release.


18-24: Verify the new materialization default.

The +materialized: table configuration will materialize all models under poke_cli_dbt as tables by default. Confirm this is intentional and won't cause issues with any models that should remain views or incremental.

Note: The AI summary indicated the on-run-end hook was removed, but it's still present (lines 23-24).

.goreleaser.yml (1)

17-17: LGTM!

Version bump to v1.8.6 is consistent with Dockerfile and other build configurations.

card_data/README.md (1)

10-10: LGTM!

The switch to a local image reference is appropriate for documentation maintainability. The image file data_infrastructure_v2.png exists in the card_data/ directory as expected.

README.md (1)

5-5: LGTM!

Version references updated consistently to v1.8.6 across the Docker image badge and usage examples.

Also applies to: 99-99, 103-103

.github/workflows/ci.yml (1)

34-34: LGTM!

The VERSION_NUMBER environment variable is the single source of truth for the version across the CI workflow. The bump to v1.8.6 is correctly propagated to all build, packaging, and deployment steps.

nfpm.yaml (1)

4-4: LGTM!

Version bump to v1.8.6 in packaging metadata aligns with the coordinated release across the project.

go.mod (1)

50-50: The closestmatch dependency is actively used and necessary.

This library is used in cmd/search/parse.go for fuzzy string matching with specific bag size parameters (2, 3, 4). While the +incompatible suffix indicates it's a pre-Go-modules package and hasn't been updated in several years, it's functional for the use case and actively utilized in the codebase.

Note: sahilm/fuzzy exists in dependencies but is not used anywhere in the codebase, so it cannot serve as a replacement for closestmatch.

card_data/pipelines/poke_cli_dbt/models/cards.sql (1)

6-8: Verify that filtering non-numeric localId values is intentional.

The WHERE clause "localId" ~ '^[0-9]+$' will exclude cards with alphanumeric identifiers (e.g., promo cards like "SWSH001", "TG01", or special edition cards). Ensure this doesn't inadvertently filter out legitimate card data that should be included in the pipeline.

The regulation_mark column addition looks good.

#!/bin/bash
# Check if there are cards with non-numeric localId values that would be filtered out
# This helps understand the impact of the WHERE clause

# Look for related SQL files or documentation about localId format
fd -e sql -e md | xargs rg -l "localId" 2>/dev/null | head -10

# Check for any comments or documentation about the localId filtering
rg -n "localId" --type sql -C2
cmd/card/setslist_test.go (1)

195-198: LGTM!

The use of the shared testSupabaseKey constant from cardlist_test.go is appropriate since both test files belong to the same card package. This improves maintainability by centralizing the test API key.

card_data/pipelines/poke_cli_dbt/macros/create_view.sql (1)

13-14: LGTM!

The regulation_mark field is correctly propagated through the CTE and final SELECT. The addition of set_name to the CTE aligns with its existing usage in the outer SELECT at line 30.

Also applies to: 34-35

cmd/card/cardlist_test.go (2)

14-17: LGTM!

Good refactoring to extract the test API key into a named constant. The documentation comment clearly explains the purpose, and centralizing this value improves maintainability across the test suite.


312-315: LGTM!

Header assertions correctly reference the centralized constant.

cmd/search/parse_test.go (2)

11-16: LGTM!

Good expansion of the mock data to provide sufficient coverage for the various regex pattern tests.


150-151: LGTM!

The query test correctly validates regex filtering with the .*chu.* pattern matching both "pikachu" and "raichu".

cmd/card/cardlist.go (4)

16-27: LGTM!

The CardsModel struct extension with RegulationMarkMap follows the same pattern as existing maps (IllustratorMap, ImageMap, PriceMap) for consistency.


74-76: LGTM!

The view rendering properly retrieves the regulation mark from the map and displays it alongside other card details. The fallback value is set during map population in CardsList, maintaining consistency with the illustrator field handling pattern.


95-102: LGTM!

The cardData struct and API query are correctly extended to include regulation_mark. The JSON tag matches the expected API response field name.

Also applies to: 106-106


138-143: LGTM!

The regulation mark handling mirrors the pattern used for illustrator, providing a clear fallback message when the field is empty.

cmd/search/parse.go (3)

29-42: LGTM with a note on regex safety.

The implementation is correct. Go's regexp package uses a linear-time matching algorithm (RE2-based), so it's inherently safe from ReDoS attacks even with user-supplied patterns.


69-75: LGTM!

The refactored parseSearch cleanly delegates to the appropriate strategy based on query content and properly propagates errors from the regex path.


86-89: LGTM!

Error handling is properly integrated into the query function, ensuring regex compilation failures are surfaced to callers.

@digitalghost-dev digitalghost-dev merged commit 8df42ca into main Jan 14, 2026
8 checks passed
@digitalghost-dev digitalghost-dev deleted the 1.8.6 branch January 14, 2026 22:00
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.

Add regulation mark to card Deduplicate command list in cli.go Add regex and fuzzy searching functionalities to search command

2 participants