Allow every object type as a dependency key (L8)#57
Conversation
`ObjectType::from_plural_key` already recognized all 25 object types, but schemata/dependencies.yml listed only nine plural keys under `additionalProperties: false`, so a `dependencies:` block naming an aggregate, collation, event_trigger, materialized_view, publication, server, subscription, user, or user_mapping was rejected at validation before the loader ever saw it — you could depend on `views` but not `materialized_views`. This was carried over from Python's OBJ_KEYS; per the maintainer, 2.0 need not preserve that limitation. Add the nine missing keys (schema-qualified pattern for the schema-scoped types, bare for the schemaless ones). Resolution already works: the loader's `index_key` normalizes the namespace to None for schemaless types on both insert and lookup, and `from_plural_key` maps the keys. A new validate test confirms the widened keys pass and unknown keys are still rejected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR expands the JSON Schema for PostgreSQL dependency objects to include new top-level properties (aggregates, collations, materialized_views, publications, servers, subscriptions, user_mappings, users) and adds a unit test validating the widened schema and rejection of unknown keys. ChangesDependencies schema expansion
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🤖 This comment was posted by Claude on behalf of @gmr CI is green and there are no open review threads, but the CodeRabbit status check is still pending. Re-triggering a review. @coderabbitai review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/project/validate.rs (1)
129-159: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winTest correctly exercises
validator_for/iter_errors, but silently doesn't catch thepropertyNames-on-array schema gap.The test data uses arrays of plain strings for every widened key (e.g.
"aggregates": ["test.agg"]), which is exactly the instance shape for whichpropertyNamesindependencies.ymlis a no-op. As a result this test only verifies that the keys are accepted (which they would be even with malformed names like"aggregates": ["not-a-schema-qualified-name"]) — it does not actually verify name-format enforcement. Once thepropertyNames/itemsissue inschemata/dependencies.ymlis fixed, consider adding a negative case here with a malformed item value (e.g."aggregates": ["missing_dot"]) to confirm the pattern constraint is enforced.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/project/validate.rs` around lines 129 - 159, The dependencies validation test in validate::dependencies_schema_accepts_every_object_type only checks that widened keys pass validator_for/iter_errors, but it never verifies item-name pattern enforcement because the schema gap is on array items rather than the keys themselves. Update this test to add a negative case using a malformed dependency name value for one of the widened keys, and assert validator.iter_errors returns an error so the pattern constraint is actually exercised alongside the existing accepted/unknown-key checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@schemata/dependencies.yml`:
- Around line 7-22: Update the dependency array schemas in the dependencies
definition so the string validation applies to array elements instead of object
keys; in the affected dependency entries like aggregates, collations, domains,
and event_triggers, replace propertyNames-based validation with items-based
pattern validation, and make the same change for the other dependency arrays in
this file so each dependency string is actually checked.
---
Nitpick comments:
In `@src/project/validate.rs`:
- Around line 129-159: The dependencies validation test in
validate::dependencies_schema_accepts_every_object_type only checks that widened
keys pass validator_for/iter_errors, but it never verifies item-name pattern
enforcement because the schema gap is on array items rather than the keys
themselves. Update this test to add a negative case using a malformed dependency
name value for one of the widened keys, and assert validator.iter_errors returns
an error so the pattern constraint is actually exercised alongside the existing
accepted/unknown-key checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f9b6b7da-6744-445c-9966-7697f5da12a5
📒 Files selected for processing (2)
schemata/dependencies.ymlsrc/project/validate.rs
|
PR monitoring complete — ready to merge.
No code changes were needed this session beyond addressing review feedback. |
Closes the last substantive item from the review-findings audit (L8).
Problem
ObjectType::from_plural_key(src/constants.rs) already recognizes all 25 object types, butschemata/dependencies.ymllisted only nine plural keys underadditionalProperties: false. Because per-object validation runs before thedependenciesblock is stripped, adependencies:block naming an aggregate, collation, event_trigger, materialized_view, publication, server, subscription, user, or user_mapping was rejected at validation — you could depend onviewsbut notmaterialized_views. Carried over from Python'sOBJ_KEYS; per the maintainer, 2.0 need not preserve that limitation.Change
schemata/dependencies.yml(schema-qualifiedschema.namepattern for the schema-scoped types; bare pattern for the schemaless ones), alphabetized with the existing keys.validatetest asserting the widened keys validate and unknown keys are still rejected byadditionalProperties: false.Resolution already works end-to-end for these types: the loader's
index_keynormalizes the namespace toNonefor schemaless types on both insert and lookup, andfrom_plural_keymaps the keys — so no loader change is needed. (propertyNameson atype: arrayis a JSON-Schema no-op, matching the existing entries, so the patterns are cosmetic;additionalPropertiesis the functional gate.)Validation
just check— fmt, clippy-D warnings, all tests pass (newdependencies_schema_accepts_every_object_type).just gates— round-trip + all three deploy gates pass.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests