Skip to content

[copilot] Restrict frontmatter schema with additionalProperties: false, align with GitHub Actions schema, and add tests #131

@pelikhan

Description

@pelikhan

Summary

Strengthen the validation of frontmatter schemas by setting additionalProperties: false at all levels and aligning allowed keys with the official GitHub Actions schema. Several types currently allow additional properties, resulting in weak validation and acceptance of unexpected keys.

Tasks

  1. List and add missing attributes
    • Compare the current schema against the official GitHub Actions workflow schema and enumerate missing/extra attributes.
    • Ensure support for both standard GitHub Actions frontmatter and the additional features currently supported by this project.
  2. Update schema
    • In pkg/parser/schemas/main_workflow_schema.json, set additionalProperties: false at every object level (where applicable).
    • Restrict types more tightly for all fields, matching the GitHub Actions specification and project extensions.
    • Remove or relocate any properties not compatible with the schema.
  3. Improve and add tests
    • Update and expand tests in pkg/parser/schema_test.go and pkg/parser/schema_location_test.go to ensure invalid keys are rejected and all expected keys/values are accepted.
    • Test both valid and invalid frontmatter, including edge cases (see existing test cases for examples of both valid and invalid scenarios).

Relevant Code

Schema validation implementation:

  • pkg/parser/schema.go
  • Functions: ValidateMainWorkflowFrontmatterWithSchema, validateWithSchema, validateWithSchemaAndLocation

Existing test coverage:

Acceptance Criteria

  • The schema disallows any properties not explicitly listed (using additionalProperties: false).
  • All required and optional attributes are present and validated according to the latest GitHub Actions schema and project extensions.
  • Tests cover both positive and negative cases (invalid keys, wrong types, missing required fields, etc.).

References:


Example test cases (see more in schema_test.go):

// Invalid properties should fail
frontmatter := map[string]any{"on": "push", "invalid_key": "value"} // error: additional properties not allowed
// Valid properties (should pass)
frontmatter := map[string]any{"on": "push", "engine": "claude"}

If you have questions about which properties are supported, consult the official schema and the current test cases in the codebase.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions