Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Summary

Consolidates scattered generic validation functions from multiple files into the central pkg/workflow/validation.go file, while keeping domain-specific validation in their respective files. This improves code organization and maintainability.

Closes #2273 (partial - validation consolidation component)

Changes

Functions Moved to validation.go

Three generic validation functions were identified and moved to the central validation file:

  1. validateGitHubActionsSchema (from compiler.go)

    • Validates generated YAML against the GitHub Actions workflow schema
    • Generic schema validation applicable to any workflow
  2. validateNoDuplicateCacheIDs (from cache.go)

    • Checks for duplicate cache memory IDs
    • Generic data validation with no domain-specific logic
  3. validateSecretReferences (from redact_secrets.go)

    • Validates secret name format using regex pattern matching
    • Generic format validation independent of secret redaction logic

Domain-Specific Validation Retained

The following validation functions were intentionally kept in their domain files as they contain domain-specific logic:

  • compiler.go: validateHTTPTransportSupport, validateMaxTurnsSupport, validateWebSearchSupport (engine-specific validation)
  • docker.go: validateDockerImage (Docker-specific)
  • npm.go: validateNpxPackages (npm/Node-specific)
  • pip.go: validatePipPackages, validateUvPackages, etc. (Python package-specific)
  • expression_safety.go: validateExpressionSafety, validateSingleExpression (expression parsing-specific)
  • strict_mode.go: All strict mode validation functions (strict mode policy-specific)

Technical Details

  • Added necessary imports to validation.go: encoding/json, regexp, go-yaml, jsonschema/v6
  • Removed unused jsonschema import from compiler.go
  • All function calls continue to work correctly with no breaking changes
  • Net code change: +76 lines added, -73 lines removed (3-line difference for improved organization)

Testing

  • ✅ All unit tests pass: make test-unit
  • ✅ Build successful: make build
  • ✅ No changes to function signatures or behavior
  • ✅ All existing callers continue to work without modification

Benefits

  • Clearer separation of concerns: Generic validation logic is now centralized in one location
  • Easier to maintain: Developers know where to find and add generic validation functions
  • Better code organization: Domain-specific validation remains with its related domain logic
  • No breaking changes: All existing code continues to work as before
Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Consolidate generic validation functions into validation.go</issue_title>
<issue_description>## Objective
Consolidate scattered generic validation functions from multiple files into the central pkg/workflow/validation.go file, while keeping domain-specific validation in their respective files.

Context

Part of issue #2273. Validation logic is scattered across 12 files with 35+ validation functions. Generic validation functions should be centralized in validation.go, while domain-specific validation (e.g., Docker, npm, pip, expression safety) should remain in domain files.

Functions to Move to validation.go

From compiler.go (4 validation functions):

  • Move generic validation functions (identify during implementation)

From cache.go:

  • validateNoDuplicateCacheIDs

From redact_secrets.go:

  • validateSecretReferences

Functions to KEEP in Domain Files

These should NOT be moved (domain-specific validation):

  • expression_safety.go: validateExpressionSafety, validateSingleExpression
  • docker.go: validateDockerImage
  • npm.go: validateNpxPackages
  • pip.go: validatePipPackages, validateUvPackages, etc.
  • strict_mode.go: validateStrictMode, validateStrictPermissions

Approach

  1. Review all validation functions in compiler.go to identify generic ones
  2. Move generic validation functions to validation.go
  3. Move validateNoDuplicateCacheIDs from cache.go
  4. Move validateSecretReferences from redact_secrets.go
  5. Keep domain-specific validation in their respective files
  6. Update imports and references

Files to Modify

  • Update: pkg/workflow/validation.go (add moved functions)
  • Update: pkg/workflow/compiler.go (remove generic validation)
  • Update: pkg/workflow/cache.go (remove validateNoDuplicateCacheIDs)
  • Update: pkg/workflow/redact_secrets.go (remove validateSecretReferences)

Acceptance Criteria

AI generated by Plan Command for #2273</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #2277


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Oct 24, 2025
Copilot AI and others added 2 commits October 24, 2025 11:58
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Moved validateGitHubActionsSchema from compiler.go to validation.go
- Moved validateNoDuplicateCacheIDs from cache.go to validation.go
- Moved validateSecretReferences from redact_secrets.go to validation.go
- Removed unused jsonschema import from compiler.go
- All tests pass, build successful

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review October 24, 2025 12:06
Copilot AI changed the title [WIP] Consolidate generic validation functions into validation.go Consolidate generic validation functions into validation.go Oct 24, 2025
@github-actions
Copy link
Contributor

Agentic Changeset Generator triggered by this pull request.

Copilot AI requested a review from pelikhan October 24, 2025 12:07
@pelikhan pelikhan merged commit d781a56 into main Oct 24, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/consolidate-validation-functions branch October 24, 2025 12:15
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.

[task] Consolidate generic validation functions into validation.go [refactor] 🔧 Semantic Function Clustering Analysis - Refactoring Opportunities

2 participants