Skip to content

Fix gh aw add parsing for long hyphenated repository names#37960

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-gh-aw-add-workflow-parsing
Jun 8, 2026
Merged

Fix gh aw add parsing for long hyphenated repository names#37960
pelikhan merged 3 commits into
mainfrom
copilot/fix-gh-aw-add-workflow-parsing

Conversation

Copilot AI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

gh aw add incorrectly rejected valid workflow specs when the repository segment exceeded owner-name length assumptions (e.g., long hyphenated repo names). This caused valid owner/repo/path/to/workflow.md inputs to fail early as “not a valid workflow path or repository package.”

  • Problem scope

    • Repository-name validation reused owner/org constraints, which are stricter than repo-name constraints.
    • This impacted workflow-spec parsing and repository-package-spec detection.
  • Parser changes

    • Split identifier validation by semantic role:
      • owner/org: IsValidGitHubIdentifier (existing behavior)
      • repo: IsValidGitHubRepositoryName (new, repo-appropriate max length)
    • Added a shared internal validator helper and explicit owner/repo length constants.
  • CLI integration updates

    • Updated workflow spec parsing (pkg/cli/spec.go) to validate owner and repo with role-correct validators.
    • Updated package spec parsing (pkg/cli/add_package_manifest.go) with the same owner/repo split.
  • Regression coverage

    • Added a focused workflow-spec test for a long hyphenated repo with explicit .md path.
    • Added parser tests covering valid long repo names and >100-char invalid names.
// before
if !parser.IsValidGitHubIdentifier(owner) || !parser.IsValidGitHubIdentifier(repo) { ... }

// after
if !parser.IsValidGitHubIdentifier(owner) || !parser.IsValidGitHubRepositoryName(repo) { ... }

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix gh aw add parsing issue with hyphenated repository names Fix gh aw add parsing for long hyphenated repository names Jun 8, 2026
Copilot AI requested a review from pelikhan June 8, 2026 23:10
@pelikhan pelikhan marked this pull request as ready for review June 8, 2026 23:21
Copilot AI review requested due to automatic review settings June 8, 2026 23:21
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer failed during the skills-based review.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #37960 does not have the 'implementation' label and has only 69 new lines in business logic directories (≤100 threshold, no custom .design-gate.yml config).

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel completed test quality analysis.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes gh aw add spec parsing to correctly accept workflow and package specs when the repository name is longer than the 39-character owner/org limit (common with long hyphenated repo names), by splitting validation rules for owner/org vs repo.

Changes:

  • Introduced a repo-specific validator (IsValidGitHubRepositoryName) with a 100-character max length while keeping owner/org validation at 39.
  • Updated CLI parsing to validate owner and repo with role-correct validators in workflow-spec and repository-package-spec parsing.
  • Added regression tests for the new repo-name validator and for parsing a workflow spec with a long hyphenated repo name.
Show a summary per file
File Description
pkg/parser/github_urls.go Adds shared validator helper, owner/repo max-length constants, and a new repo-name validator.
pkg/parser/github_urls_test.go Adds unit tests for IsValidGitHubRepositoryName.
pkg/cli/spec.go Updates workflow URL/spec parsing to validate repo names with the repo-specific validator.
pkg/cli/add_wildcard_test.go Adds a regression test for parsing a long hyphenated repo name in a direct workflow path spec.
pkg/cli/add_package_manifest.go Updates repository-package spec detection to validate repo names with the repo-specific validator.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 3

Comment thread pkg/parser/github_urls.go
Comment on lines +377 to +380
// IsValidGitHubIdentifier checks if a string is a valid GitHub user or organization identifier.
func IsValidGitHubIdentifier(s string) bool {
return isValidGitHubNameWithMaxLength(s, maxGitHubOwnerIdentifierLength)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in e31d8ee. I corrected the parser API docs in pkg/parser/README.md to split owner/org vs repository validation and added README-backed spec coverage for IsValidGitHubRepositoryName in pkg/parser/spec_test.go.

Comment thread pkg/cli/spec.go
Comment on lines 208 to 211
// Validate owner and repo
if !parser.IsValidGitHubIdentifier(owner) || !parser.IsValidGitHubIdentifier(repo) {
if !parser.IsValidGitHubIdentifier(owner) || !parser.IsValidGitHubRepositoryName(repo) {
return nil, fmt.Errorf("invalid GitHub URL: '%s/%s' does not look like a valid GitHub repository", owner, repo)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in e31d8ee. pkg/cli/spec_github_url_test.go now includes a parseGitHubURL regression case with a long hyphenated repo segment (>39 chars).

Comment on lines 787 to 792
slashParts := strings.Split(specWithoutVersion, "/")
if len(slashParts) < 2 || slashParts[0] == "" || slashParts[1] == "" {
return nil, false, nil
}
if !parser.IsValidGitHubIdentifier(slashParts[0]) || !parser.IsValidGitHubIdentifier(slashParts[1]) {
if !parser.IsValidGitHubIdentifier(slashParts[0]) || !parser.IsValidGitHubRepositoryName(slashParts[1]) {
return nil, false, nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled in e31d8ee. TestParseRepositoryPackageSpec now includes a long hyphenated repo-name case (>39 chars) to keep repository-package parsing covered for this regression.

@github-actions github-actions Bot mentioned this pull request Jun 8, 2026
@pelikhan

pelikhan commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 100/100 — Excellent

Analyzed 2 test functions (5 scenarios across table rows): 2 design tests, 0 implementation tests, 0 guideline violations.

📊 Metrics & Test Classification (2 tests analyzed)
Metric Value
New/modified tests analyzed 2
✅ Design tests (behavioral contracts) 2 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 2 (100%)
Duplicate test clusters 0
Test inflation detected No
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Notes
TestParseWorkflowSpecWithWildcard (new row) pkg/cli/add_wildcard_test.go:66 ✅ Design Regression test — verifies the fixed behavior (long hyphenated repo name parsed correctly, non-wildcard, no error)
TestIsValidGitHubRepositoryName (4 rows) pkg/parser/github_urls_test.go:840 ✅ Design Full coverage of validation contract: valid short name, valid long hyphenated name, invalid too-long name, invalid starts-with-hyphen

Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 2 test functions — unit (//go:build !integration)
  • 🟨 JavaScript (*.test.cjs, *.test.js): 0 tests

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). Both tests assert on observable behavioral contracts, cover error/edge-case paths, and align directly with the bug being fixed.

📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

🧪 Test quality analysis by Test Quality Sentinel · 172 AIC · ⌖ 25.4 AIC ·

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 100/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). Both tests assert on observable behavioral contracts and cover the exact edge cases addressed by this fix.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan merged commit a02e9d1 into main Jun 8, 2026
29 checks passed
@pelikhan pelikhan deleted the copilot/fix-gh-aw-add-workflow-parsing branch June 8, 2026 23:49
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.

gh aw add fails to parse valid workflow path when repository name contains multiple hyphens

3 participants