Conversation
…on invalid port Agent-Logs-Url: https://github.com/github/gh-aw/sessions/053ff2b4-7c30-485b-9c0e-f3d9ea568a39 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors engine registration to return a recoverable error instead of panicking when an engine has an invalid dedicatedLLMGatewayPort, enabling testable validation paths while keeping built-in engine registration fail-fast.
Changes:
- Changed
EngineRegistry.Registerto returnerrorand replaced the negative-portpanicwith a validation error. - Updated
NewEngineRegistryto register built-in engines in a loop and terminate on registration failure. - Updated/extended unit tests to assert
Registersucceeds for valid engines and returns an error for a negative port engine.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/agentic_engine.go | Updates Register to return error; updates built-in engine registration to handle errors (currently via stderr + os.Exit(1)). |
| pkg/workflow/agentic_engine_test.go | Updates Register call sites to assert NoError; adds a new negative-port regression test helper type and test case. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 3
| // Register adds an engine to the registry. It returns an error if the engine | ||
| // has an invalid configuration (e.g., dedicatedLLMGatewayPort < 0). | ||
| func (r *EngineRegistry) Register(engine CodingAgentEngine) error { | ||
| type portProvider interface{ getDedicatedLLMGatewayPort() int } | ||
| if p, ok := engine.(portProvider); ok && p.getDedicatedLLMGatewayPort() < 0 { | ||
| panic(fmt.Sprintf("engine '%s': dedicatedLLMGatewayPort must be >= 0, got %d", engine.GetID(), p.getDedicatedLLMGatewayPort())) | ||
| return fmt.Errorf("engine '%s': dedicatedLLMGatewayPort must be >= 0, got %d", engine.GetID(), p.getDedicatedLLMGatewayPort()) | ||
| } | ||
| agenticEngineLog.Printf("Registering engine: id=%s, name=%s", engine.GetID(), engine.GetDisplayName()) | ||
| r.engines[engine.GetID()] = engine | ||
| return nil |
| fmt.Fprintf(os.Stderr, "fatal: failed to register built-in engine: %v\n", err) | ||
| os.Exit(1) |
|
|
||
| // negativePortEngine wraps ClaudeEngine and returns -1 from | ||
| // getDedicatedLLMGatewayPort, triggering the validation path in Register. | ||
| err := registry.Register(&negativePortEngine{CodingAgentEngine: NewClaudeEngine()}) | ||
| require.Error(t, err, "registering an engine with dedicatedLLMGatewayPort = -1 should return an error") | ||
| assert.Contains(t, err.Error(), "dedicatedLLMGatewayPort must be >= 0", "error message should describe the constraint") |
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification DetailsView all test details
Analysis NotesAll three changes are high-quality:
Minor cosmetic note: There is a typo in one assertion message — Build tag: ✅ 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.
|
|
@copilot review all comments |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/05838d4b-61f4-445f-aa7b-17f63b64f105 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed all three reviewer comments in f44a14c:
|
EngineRegistry.Registerpanicked ondedicatedLLMGatewayPort < 0, making misconfiguration an unrecoverable crash with no testable path.Changes
Registersignature:Register(engine CodingAgentEngine)→Register(engine CodingAgentEngine) error; replacespanicwith anerrorreturnNewEngineRegistry: loops over built-in engines and handles registration errors viapanic(fmt.Sprintf(...)), preserving fail-fast semantics with stack traces and deferred cleanup intact (avoidsos.Exitin library code)engine_config_render_test.goandengine_definition_test.goto handle theerrorreturn fromRegisterusingrequire.NoErrorRegistercall sites to assertNoError; added new test case confirming an engine with port-1returns an error rather than panicking, and that the engine is not registered on failure