Skip to content

Validator crashes for ALL components when ONE schema has invalid syntax (misleading error reporting) #458

Description

@schalkneethling

Description

When running miyagi lint, if a single component schema is syntactically invalid (specifically, valid YAML but invalid JSON Schema, such as properties: null), the linter fails for every single component in the project.

The error message reported for every component is identical (e.g., Error: schema is invalid: data/properties must be object), making it impossible to determine which specific file is actually causing the issue without manually checking or debugging every schema file.

Reproduction Steps

  1. Create a valid Miyagi project with multiple components (e.g., button, card, hero).
  2. Create a new component (e.g., social-share) with a schema.yaml that parses to properties: null.
    $schema: http://json-schema.org/draft-07/schema
    $id: /patterns/social-share
    type: object
    additionalProperties: false
    # This key with no value parses as null in YAML
    properties:
  3. Run miyagi lint.

Expected Behavior

The linter should fail only for the social-share component and provide an error message indicating that social-share/schema.yaml is invalid. Other valid components should pass linting.

Actual Behavior

The linter reports errors for every single component in the system.

  • social-share: Reports Error: schema is invalid: data/properties must be object
  • button (valid): Reports Error: schema is invalid: data/properties must be object
  • card (valid): Reports Error: schema is invalid: data/properties must be object

This suggests that the validator context is loading all schemas globally to resolve $ref, and a single failure crashes the initialization of the validator for every subsequent check.

Context

  • Miyagi Core Version: 4.0.0
  • Validator: AJV (via internal dependency)

It appears the validator compiles all project schemas into the context to handle references. When one fails compilation (due to the schema spec requiring properties to be an object, not null), the error bubbles up as a generic failure for the current component being linted, effectively masking the root cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions