Skip to content

feat: allow '-' and '/' in object IDs#624

Merged
SoulPancake merged 2 commits into
mainfrom
feat/allow-more-id-chars
Jul 4, 2026
Merged

feat: allow '-' and '/' in object IDs#624
SoulPancake merged 2 commits into
mainfrom
feat/allow-more-id-chars

Conversation

@SoulPancake

@SoulPancake SoulPancake commented Jul 3, 2026

Copy link
Copy Markdown
Member

Extend the object ID validation rule to permit '-' and '/' ('|' already allowed) across the Go, JS, and Java validators, matching characters the server accepts. Type/relation/condition rules unchanged. Closes #437.

Description

What problem is being solved?

How is it being solved?

What changes are made to solve it?

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • New Features

    • Identifier validation now accepts - and / in non-leading positions across Go, Java, and JavaScript implementations.
  • Tests

    • Added coverage for IDs containing dashes, slashes, and mixed special characters to confirm the updated validation behavior.

Extend the object ID validation rule to permit '-' and '/' ('|'
already allowed) across the Go, JS, and Java validators, matching
characters the server accepts. Type/relation/condition rules
unchanged. Closes #437.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 29e1468e-8a45-47bc-a886-c29108479859

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The ID validation regex pattern is updated in Go, Java, and JavaScript implementations to allow / and - characters in identifier values beyond the first character. Corresponding test cases are added in each language to verify acceptance of these new characters.

Changes

ID Regex Update Across Languages

Layer / File(s) Summary
Go RuleID regex update
pkg/go/validation/validation-rules.go, pkg/go/validation/validation-rules_test.go
RuleID regex extended to allow / and - in trailing characters; test cases added for dash, slash, and mixed-character IDs.
Java Rules.ID regex update
pkg/java/src/main/java/dev/openfga/language/validation/Validator.java, pkg/java/src/test/java/dev/openfga/language/validation/ValidationRules.java
Rules.ID regex extended to allow / and -; new assertTrue test cases added for dash, slash, and mixed-character object IDs.
JS Rules.id regex update
pkg/js/validator/validate-rules.ts, pkg/js/tests/validate-rules.test.ts
Rules.id regex extended to allow / and -; new passing test cases added for dash, slash, and mixed-character object IDs.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested Labels

validation, enhancement

Suggested Reviewers

None identified from the provided context.

Poem

A dash, a slash, now join the fray,
Three languages agree today.
Go, Java, JS — in perfect rhyme,
IDs grow richer, one small line.
🐰 Hop, hop, validate away!

🚥 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 summarizes the main change: allowing new characters in object IDs.
Linked Issues check ✅ Passed The Go, JS, and Java validators now allow the requested object ID characters without changing relation, type, or condition name rules.
Out of Scope Changes check ✅ Passed The changes stay within the validation updates and accompanying tests described by the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/allow-more-id-chars

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.

@SoulPancake SoulPancake marked this pull request as ready for review July 3, 2026 18:25
@SoulPancake SoulPancake requested a review from a team as a code owner July 3, 2026 18:25
Copilot AI review requested due to automatic review settings July 3, 2026 18:25
@SoulPancake SoulPancake requested a review from a team as a code owner July 3, 2026 18:25

Copilot AI 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.

Pull request overview

This PR updates the OpenFGA DSL object ID validation regex across the Go, JS, and Java implementations to allow - and / (in addition to existing allowed characters like |), aligning the language validators with characters accepted by the server.

Changes:

  • Expanded the object ID regex character class to include - and / in Go, JS, and Java validators.
  • Added/updated test cases in Go, JS, and Java to assert that IDs containing - and / are accepted.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/js/validator/validate-rules.ts Updates the JS object ID validation regex to include - and /.
pkg/js/tests/validate-rules.test.ts Adds JS unit tests covering IDs containing - and /.
pkg/java/src/main/java/dev/openfga/language/validation/Validator.java Updates the Java object ID validation regex to include - and /.
pkg/java/src/test/java/dev/openfga/language/validation/ValidationRules.java Adds Java unit tests covering IDs containing - and /.
pkg/go/validation/validation-rules.go Updates the Go object ID validation regex to include - and /.
pkg/go/validation/validation-rules_test.go Adds Go unit tests covering IDs containing - and /.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/js/validator/validate-rules.ts Outdated
Comment thread pkg/java/src/main/java/dev/openfga/language/validation/Validator.java Outdated
Comment thread pkg/go/validation/validation-rules.go Outdated
Comment thread pkg/js/tests/validate-rules.test.ts Outdated
Comment thread pkg/go/validation/validation-rules_test.go Outdated
Comment thread pkg/java/src/test/java/dev/openfga/language/validation/ValidationRules.java Outdated

@rhamzeh rhamzeh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A minor note in case you can quickly spike it - would you mind trying to see if you can move the test cases to the common yaml so that we don't have to write them 3 times and ensure they're all consistent with each other?

Not a blocker - just a quick spike

… regex

Escape '-' as '\-' in the object-ID regex (Go, JS, Java) so it is
unambiguously a literal rather than a range, and move the object-ID
validation test cases into a shared tests/data/object-id-validation-cases.yaml
consumed by all three implementations. Adds a regression case ensuring
','  remains invalid.

Refs #437
@SoulPancake SoulPancake requested a review from rhamzeh July 3, 2026 19:02
@SoulPancake SoulPancake added this pull request to the merge queue Jul 4, 2026
Merged via the queue into main with commit e9a8cce Jul 4, 2026
26 checks passed
@SoulPancake SoulPancake deleted the feat/allow-more-id-chars branch July 4, 2026 00:31
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.

Update the Validation rules to account for allowing more characters

3 participants