Skip to content

fix: correct element-attributes type and harden schema cache#258

Merged
mcanouil merged 1 commit intomainfrom
fix/schema-review-round1
Feb 15, 2026
Merged

fix: correct element-attributes type and harden schema cache#258
mcanouil merged 1 commit intomainfrom
fix/schema-review-round1

Conversation

@mcanouil
Copy link
Copy Markdown
Owner

Summary

  • Fix elementAttributes type from flat Record<string, FieldDescriptor> to grouped Record<string, Record<string, FieldDescriptor>> matching the actual _schema.yml structure where attributes are nested under CSS class or element type keys (e.g., _any, panel, card).
  • Make SchemaCache.get() exception-safe by catching errors from malformed schema files and returning null, preventing one broken _schema.yml from crashing the tree view, completions, or diagnostics.
  • Add Array.isArray guard in parseSchemaContent to reject YAML arrays at root level.
  • Standardise Array.isArray guards across all normaliseSchema sections for consistency.

Test plan

  • All 415 core tests pass.
  • TypeScript compilation clean (tsc --noEmit).
  • New tests: YAML array rejection, YAML scalar rejection, cache returns null for malformed schema, cache returns null for invalid YAML syntax.
  • Updated tests: element-attributes now use two-level nesting structure.

- Change elementAttributes type from flat Record<string, FieldDescriptor>
  to grouped Record<string, Record<string, FieldDescriptor>> matching
  the actual _schema.yml structure (class-name -> attributes).
- Make SchemaCache.get() exception-safe by catching errors from malformed
  schema files and returning null instead of propagating.
- Add Array.isArray guard in parseSchemaContent to reject YAML arrays
  at root level.
- Standardise Array.isArray guards across all normaliseSchema sections.
- Add tests for array/scalar YAML rejection and cache error handling.
- Wrap tempDir2 cleanup in try/finally in invalidateAll test.
@mcanouil mcanouil added the Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses label Feb 15, 2026
@mcanouil mcanouil self-assigned this Feb 15, 2026
@mcanouil mcanouil added the Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses label Feb 15, 2026
@mcanouil mcanouil merged commit 6b46f23 into main Feb 15, 2026
7 checks passed
@mcanouil mcanouil deleted the fix/schema-review-round1 branch February 15, 2026 17:22
@mcanouil mcanouil added Type: Bug 🐛 Issues related to bugs, errors, or mistakes and removed Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses labels Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug 🐛 Issues related to bugs, errors, or mistakes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant