Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Runtime-import files were only validated at runtime, allowing workflows with invalid expressions to pass compilation and fail later during execution.

Changes

Expression validation (pkg/workflow/expression_validation.go):

  • extractRuntimeImportPaths() - Extracts file paths from {{#runtime-import filepath}} syntax, filtering out URLs
  • validateRuntimeImportFiles() - Reads imported files and validates expressions against the allowed list at compile time

Compiler integration (pkg/workflow/compiler.go):

  • Added validation step after main markdown validation, before YAML generation
  • Resolves workspace directory from workflow path to locate imported files

Test coverage (pkg/workflow/runtime_import_validation_test.go):

  • Path extraction with various formats and edge cases
  • Validation with safe/unsafe expressions, optional imports, non-existent files
  • Compiler integration tests

Example

With a shared file containing unsafe expressions:

<!-- .github/shared/instructions.md -->
Token: ${{ secrets.GITHUB_TOKEN }}
Runner: ${{ runner.os }}

Compilation now fails early:

✗ test-workflow.md:1:1: error: runtime-import files contain expression errors:

./shared/instructions.md: unauthorized expressions:
  - secrets.GITHUB_TOKEN
  - runner.os

Previously this would compile successfully and fail at runtime.

Note: This PR only supports the {{#runtime-import}} macro syntax. The @./path inline syntax was removed from the main branch and is not supported.

Original prompt

The compiler should do a sanity validation of runtime-imports files at compile time to catch "existing" issues. Validate that expressions are in the allowed list.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 16, 2026 15:04
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Added extractRuntimeImportPaths() to extract file paths from runtime-import macros
- Added validateRuntimeImportFiles() to validate expressions in imported files at compile time
- Integrated validation into compiler workflow before code generation
- Added comprehensive tests for path extraction, validation, and compiler integration
- Validated manually with test workflows containing safe and unsafe expressions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Changed assert.Error to require.Error for error assertions
- Changed assert.NoError to require.NoError for success assertions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add sanity validation for runtime-imports files Add compile-time validation for runtime-import expressions Jan 16, 2026
Copilot AI requested a review from pelikhan January 16, 2026 15:26
@pelikhan pelikhan marked this pull request as ready for review January 16, 2026 15:29
@pelikhan
Copy link
Contributor

@copilot merge main and handle the removal of @ syntax

Copilot AI and others added 2 commits January 16, 2026 15:38
…ime-imports-files

# Conflicts:
#	specs/artifacts.md
- Merged origin/main into branch
- Removed @ inline syntax support from extractRuntimeImportPaths()
- Removed all tests for @ inline syntax (@./path, @../path patterns)
- Updated to align with main's removal of @ syntax in PR #10313

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 16, 2026

@copilot merge main and handle the removal of @ syntax

Done! Merged main and removed @ inline syntax support from the validation code and tests. Commit 972f35f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants