Skip to content

Conversation

@ivanauth
Copy link
Contributor

Summary

  • Fix zed validate incorrectly treating schema files with relations named "schema" as YAML validation files, causing YAML parsing errors
  • Use regex patterns to match YAML keys (schema:, schemaFile:, relationships:) only at the start of a line, avoiding false positives from relation definitions like relation schema: parent

Fixes #582

Changes

  • Modified internal/decode/decoder.go to use regex-based YAML key detection instead of simple strings.Contains
  • Added comprehensive unit tests for the new helper functions
  • Added integration test for schema files with relations named "schema"

Testing

@codecov-commenter
Copy link

codecov-commenter commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.75%. Comparing base (7ed5ab0) to head (f67c554).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
internal/decode/decoder.go 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #585      +/-   ##
==========================================
+ Coverage   39.28%   41.75%   +2.47%     
==========================================
  Files          37       37              
  Lines        5448     4771     -677     
==========================================
- Hits         2140     1992     -148     
+ Misses       3063     2520     -543     
- Partials      245      259      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ivanauth ivanauth force-pushed the fix-schema-relation-name-582 branch 2 times, most recently from ce63985 to 997a987 Compare November 26, 2025 00:24
wantErr: true,
},
{
name: "schema with relation named schema",
Copy link
Contributor

@miparnisari miparnisari Dec 8, 2025

Choose a reason for hiding this comment

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

we could also have a test "schema with permission named schema", WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree - d857b9a

miparnisari
miparnisari previously approved these changes Dec 8, 2025
@miparnisari miparnisari enabled auto-merge (squash) December 9, 2025 01:15
The zed validate command was incorrectly treating schema files containing
relations named 'schema' as YAML validation files, causing YAML parsing
errors. This happened because the code checked for 'schema:' anywhere in
the file content rather than looking for it as a YAML key at the start
of a line.

This fix uses regex patterns to match YAML keys (schema:, schemaFile:,
relationships:) only at the start of a line, avoiding false positives
from relation definitions like 'relation schema: parent'.

Fixes authzed#582
@miparnisari miparnisari force-pushed the fix-schema-relation-name-582 branch from d857b9a to f67c554 Compare December 9, 2025 01:15
@miparnisari miparnisari merged commit 1ec071e into authzed:main Dec 9, 2025
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: zed validate fails with yaml error if schema contains relation named "schema"

3 participants