additional_file_patterns no longer matches files outside empty root_dir
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start with related_files_list_builder.rb and inspect related_files_for_pattern and its owning_root_dir filter, which the issue identifies as dropping files outside configured packs. Reproduce with the given additional_file_patterns and root_dir configuration, then check that app/serializers/address.rb is annotated while existing behavior for files inside packs still works.
Written by the indexing model from the issue text.
Description
Since 4.25.0, additional_file_patterns silently returns nothing when the target file isn't inside one of the configured root_dirs. 4.24.0 and earlier work.
Steps to reproduce the problem
In a Rails app using packwerk.
packs/core/app/models/address.rb defines Address. app/serializers/address.rb exists at the app root, outside any pack.
Cause: related_files_for_pattern in related_files_list_builder.rb now has:
.select { |f| owning_root_dir(f) == model_root_dir }
owning_root_dir rejects empty root_dir entries, so a file outside every pack returns nil. The model's owner is packs/core, and "packs/core" != nil, so the file is dropped. The glob itself finds the file. Only this filter removes it.
Expected behavior
app/serializers/address.rb is annotated, as in 4.24.0.
Actual behavior
app/serializers/address.rb is ignored.
Your .annotaterb.yml configuration
:additional_file_patterns:
- app/serializers/%MODEL_NAME%.rb
:model_dir:
- packs/core/app/models
:root_dir:
- ""
- packs/core
- packs/pack1
Environment
- AnnotateRb version: 4.25.0
- Ruby version: 4.0.7
- Ruby on Rails version: 8.1.4
- Database adapter (e.g., sqlite3, pg, mysql2): pg
- Database adapter version: 1.6.3
- Dominant language
- Ruby
- Stars
- 624
- Forks
- 95
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from drwl/annotaterb
-
`v4.25.0`: enum columns declared with a Rails-side `default:` still annotate the raw value instead of the labelPossibly taken @xanagi claimed this 1 day ago. Open
Difficulty 3/5 Half a day Newbie friendliness 62/100
drwl/annotaterb#408 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
drwl/annotaterb#369 · 1 reaction ·
Maintainers usually reply within 2 days
-
`annotaterb models --delete` doesn't remove annotations from files excluded via `exclude_*`Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 65/100
drwl/annotaterb#340 · 2 comments · 1 reaction ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
drwl/annotaterb#323 · 1 comment ·
Maintainers usually reply within 2 days
-
Improve Documentation for YAML and CLI OptionsMay be free again @OdenTakashi claimed this 193 days ago, and no pull request is open. Open
drwl/annotaterb#312 · 8 comments · 1 assignee ·
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
TheOdinProject/curriculum#31465 ·
Maintainers usually reply within 1 day
-
agent:triaged bug bughunt pm:bundler priority:p1
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
SocketDev/socket-patch#1573 · 1 comment ·
Maintainers usually reply within 1 day
-
Generated server webpack config keeps Rspack's manifest and CSS extraction pluginsPossibly taken @justin808 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
shakacode/react_on_rails#5184 ·
Maintainers usually reply within 1 day
-
bug chat verified
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 6 days
-
🐞 bug pending triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
CircuitVerse/CircuitVerse#8031 · 2 comments ·
Maintainers usually reply within 1 day