feat: add ory validate opl - #456
Conversation
Closes #402. Adds a thin command over the already-wired `RelationshipAPI.CheckOplSyntax` SDK call, so that OPL files can be syntax-checked in CI/CD without the raw `curl` workaround. The command exits non-zero when the file has syntax errors. Errors are rendered compiler-style (`<source>:<line>:<column>: <message>`) on stderr for humans, and as the raw API result for the machine-readable formats. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012UL5u7KWLdu8hzNTNvYq5a
- an empty file is valid; the SDK rejects a zero-length body, so skip the call - use the nil-safe accessor for the result, which is nil on an empty response - always emit the `errors` key in machine-readable formats, so that CI scripts can rely on `jq '.errors | length'` - render the column only together with the line, so that a line-less position cannot be misread as a line number - treat an unknown `--format` as human-readable, matching cmdx itself - do not claim `update opl` validates through the same endpoint Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012UL5u7KWLdu8hzNTNvYq5a
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds a project-scoped SDK client and registers ChangesNamespace configuration validation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant CommandHelper
participant RelationshipAPI
CLI->>CommandHelper: Create project API client
CommandHelper->>RelationshipAPI: Configure selected project endpoint
CLI->>RelationshipAPI: Check OPL syntax
RelationshipAPI-->>CLI: Return parse errors
CLI-->>CLI: Format output and set exit status
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Adds
ory validate opl --file ./my-permissions.ts, a thin command over theRelationshipAPI.CheckOplSyntaxSDK call that was already vendored but unused.It replaces the raw
curlworkaround from the issue and exits non-zero onsyntax errors, so it can be used as a CI/CD check before
ory update opl.Details:
<source>:<line>:<column>: <message>) onstderr for the human-readable formats, so editors and CI log parsers pick up
the location. The machine-readable formats print the API result verbatim, with
the
errorskey always present so thatjq '.errors | length'works on thesuccess path too.
--file -reads from stdin, and errors are then reported againststdin.--quietsilences the success message but not the syntax errors.body, and a whitespace-only file — semantically identical — is valid).
The syntax check endpoint lives on the project's own API
(
<slug>.projects.oryapis.com) rather than the Console API, and there was noSDK-client helper for that host, so this also adds
CommandHelper.NewProjectAPIClient.Related Issue or Design Document
Closes #402.
Checklist
and signed the CLA.
introduces a new feature.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got approval (please contact
security@ory.com) from the maintainers to push
the changes.
works.
appropriate).
Further comments
The command is mounted under the existing
ory validateparent (next tovalidate identity) rather than as a new top-levelory checkverb, assuggested in the issue —
validatealready exists and carries the samesemantics.
🤖 Generated with Claude Code
https://claude.ai/code/session_012UL5u7KWLdu8hzNTNvYq5a
Summary by CodeRabbit
New Features
validate oplto check project namespace configuration syntax.Tests