fix: TestContainerSupport agent job detection matches manifest comments#25778
fix: TestContainerSupport agent job detection matches manifest comments#25778
Conversation
…ion to use exact line matching The tests used strings.Contains(line, "agent:") which matched manifest JSON comments containing "agent:" before reaching the actual YAML job definition. This caused the test to exit the job search prematurely. Changed to exact line matching with line == " agent:" for precise YAML key detection. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/bd9c3d91-0b94-4305-bb05-5fc0569181c7 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes flaky agent-job detection in integration tests by ensuring the scan for the agent job matches the YAML job definition line exactly (avoiding accidental matches inside the # gh-aw-manifest: JSON header comment).
Changes:
- Replace
strings.Contains(..., "agent:")with an exact match against the expected job key line (" agent:") inTestContainerSupport. - Apply the same exact-line job detection in
TestServicesSupport.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/container_services_test.go | Tightens agent job start detection to avoid false-positives from gh-aw-manifest header comments when validating container/services sections. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
| agentJobLine := " " + string(constants.AgentJobName) + ":" | ||
| for i, line := range lines { | ||
| if strings.Contains(line, string(constants.AgentJobName)+":") { | ||
| if line == agentJobLine { | ||
| inMainJob = true | ||
| continue | ||
| } | ||
| if inMainJob && strings.HasPrefix(line, " ") && !strings.HasPrefix(line, " ") && line != " "+string(constants.AgentJobName)+":" { | ||
| if inMainJob && strings.HasPrefix(line, " ") && !strings.HasPrefix(line, " ") && line != agentJobLine { |
There was a problem hiding this comment.
The agent-job detection change is applied here, but the same substring-based job detection pattern still exists in pkg/workflow/environment_test.go (see around environment_test.go:140-146). Because the generated header can include container image refs like "/agent:" inside the single-line "# gh-aw-manifest: ..." comment, that test loop is still vulnerable to the same false-positive and may keep failing CI. Consider applying the same exact-line match (or a shared helper) across all tests that scan for the agent job start.
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification Details
Summary of ChangesThis PR fixes the agent-job detection logic inside both test functions. Previously, the loop used Both
These are clean behavioral-contract tests. The fix makes the test more correct without weakening the contract being verified. Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 100/100. Test quality is excellent — 0% of new/modified tests are implementation tests (threshold: 30%). Both modified tests are behavioral-contract integration tests that exercise real compiler code, cover the happy path and an edge case (absent feature), and now use precise job-line detection to eliminate false-positive matches on manifest comments.
TestContainerSupportsubtests fail becausestrings.Contains(line, "agent:")matches the# gh-aw-manifest:JSON comment (which contains"agent:") before reaching the actual YAML job key. The test then exits the search prematurely onissues:thinking it's a new job.TestContainerSupportandTestServicesSupportsearch loops