Skip to content

fix(language): resolve @uuid version arg by name in validation - #2835

Merged
ymc9 merged 1 commit into
devfrom
fix/uuid-version-named-arg-validation
Sep 10, 2026
Merged

fix(language): resolve @uuid version arg by name in validation#2835
ymc9 merged 1 commit into
devfrom
fix/uuid-version-named-arg-validation

Conversation

@ymc9

@ymc9 ymc9 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Summary

_checkUuid in the attribute application validator assumed the version was attr.args[0]. With named arguments in a different order — e.g. @uuid(message: 'invalid uuid', version: 1) — the version was never validated, so unsupported versions slipped through; the message string landed in the version slot instead (harmless, since getNumberLiteral returns undefined, but wrong).

The validator now looks up the argument whose $resolvedParam.name is version and uses it for both the value and the diagnostic location.

Test plan

  • Added regression tests in packages/language/test/attribute-application.test.ts:
    • reordered named args (message before version) — accepts 7, rejects 1
    • message-only application stays valid
  • npx vitest run test/attribute-application.test.ts in packages/language — 42 passed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved @uuid validation for named arguments, regardless of their order.
    • Ensured validation errors are associated with the specified version argument.
    • Prevented message-only arguments from being mistaken for UUID versions.
    • UUID versions 4 and 7 remain supported; other versions continue to be rejected.
  • Tests

    • Added coverage for named arguments, invalid versions, and message-only usage.

`_checkUuid` assumed the version was `attr.args[0]`, so a named
application like `@uuid(message: '...', version: 1)` skipped validation
entirely. Look up the arg whose resolved param is `version` and use it
for both the value and the diagnostic location.

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

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 186406cd-4603-4d05-a9a3-f3dc773a2d90

📥 Commits

Reviewing files that changed from the base of the PR and between 4db005f and 76eb31b.

📒 Files selected for processing (2)
  • packages/language/src/validators/attribute-application-validator.ts
  • packages/language/test/attribute-application.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The @uuid validator now resolves the version argument by parameter name instead of position. Tests cover reordered named arguments, unsupported versions, and message-only arguments.

Changes

UUID validation

Layer / File(s) Summary
Resolve and validate the UUID version argument
packages/language/src/validators/attribute-application-validator.ts, packages/language/test/attribute-application.test.ts
_checkUuid validates the argument resolved to version and reports errors on that argument. Tests cover named argument order, invalid versions, and message-only arguments.

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

Suggested reviewers: sanny-io

Merge Risk: ⚪ Minimal · up to 76eb3

UUID validation now correctly identifies the version argument regardless of named-argument order, preserving message-only usage and reporting invalid versions at the relevant argument. The covered change is ready to merge.

🚥 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 clearly and concisely describes the main change: resolving the @uuid version argument by name during validation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/uuid-version-named-arg-validation

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/language/src/validators/attribute-application-validator.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

packages/language/test/attribute-application.test.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


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.

@ymc9
ymc9 merged commit b886207 into dev Sep 10, 2026
8 checks passed
@ymc9
ymc9 deleted the fix/uuid-version-named-arg-validation branch September 10, 2026 04:30
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