Skip to content

fix(build): interpolate class name in model dictionary lookup - #678

Closed
PhuCG wants to merge 1 commit into
GetDutchie:mainfrom
PhuCG:fix/model-dictionary-class-regex
Closed

PhuCG wants to merge 1 commit into
GetDutchie:mainfrom
PhuCG:fix/model-dictionary-class-regex

Conversation

@PhuCG

@PhuCG PhuCG commented Sep 29, 2026 •

Copy link
Copy Markdown

Fixes #677

dart test in brick_build: all pass.

🤖 Generated with Claude Code

GetDutchie#663 switched the lookup to `RegExp(r'class\s+${annotation.element.name}\s*')`.
Because it is a raw string, `${...}` is never interpolated, so no model file
matches and `brick_model_dictionary_builder` throws `Bad state: No element`
for every project on `main`.

Build the pattern with `classDeclaration(name)`:
- interpolates and escapes the class name
- keeps GetDutchie#663's support for line breaks after `class`/the name
- uses `(?![\w$])` instead of `\s*`, so `class Post` no longer matches
  `class PostDraft` (Dart identifiers can contain `$`, so `\b` is not enough)

Adds unit tests for the pattern.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PhuCG
PhuCG requested a review from tshedor as a code owner September 29, 2026 02:32
bookshiyi added a commit to insightop/brick that referenced this pull request Oct 8, 2026
Port upstream PR GetDutchie#678: the pattern added in GetDutchie#663 was a raw string, so ${...}
was never interpolated and every build failed with 'Bad state: No element'.
The pattern now also rejects longer class names sharing a prefix (Post vs PostDraft).
@dutchie-stale

dutchie-stale Bot commented Oct 10, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale due to inactivity.
It will be closed if no further activity occurs.

To keep this PR open, you can:

  • Push new changes or leave a comment
  • Add the not-stale or pinned label to exempt it from this process

@dutchie-stale dutchie-stale Bot added the stale label Oct 10, 2026
@dutchie-stale

dutchie-stale Bot commented Oct 13, 2026

Copy link
Copy Markdown

This PR has been automatically closed due to inactivity.
Feel free to reopen it if you plan to continue working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

brick_model_dictionary_builder fails with "Bad state: No element" on main (raw-string regex from #663)

1 participant