fix: typed-nil guard and _response_handled parity for PipelineRunner fallback path#121
Merged
intel352 merged 2 commits intorefactor/issue-58-route-pipeline-setter-interfacefrom Feb 23, 2026
Conversation
4 tasks
…tests Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor RoutePipelineSetter to use interfaces.PipelineRunner
fix: typed-nil guard and _response_handled parity for PipelineRunner fallback path
Feb 23, 2026
intel352
added a commit
that referenced
this pull request
Feb 23, 2026
* refactor: use interfaces.PipelineRunner in RoutePipelineSetter (closes #58) Replace the concrete *module.Pipeline type in the RoutePipelineSetter interface and the CommandHandler/QueryHandler routePipelines map with interfaces.PipelineRunner. This decouples the engine's route-pipeline wiring contract from the concrete Pipeline implementation, allowing test doubles and future plugin-provided pipelines to satisfy the interface without importing the module package. Changes: - engine.go: RoutePipelineSetter.SetRoutePipeline now takes interfaces.PipelineRunner - module/command_handler.go: routePipelines map and SetRoutePipeline use interfaces.PipelineRunner; ServeHTTP type-asserts to *Pipeline for concrete field access (Metadata, RoutePattern, Execute) with a Run()-based fallback for non-*Pipeline implementations - module/query_handler.go: same as command_handler *module.Pipeline already satisfies PipelineRunner, so engine.go callers pass *module.Pipeline unchanged — no call-site changes required there. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: typed-nil guard and _response_handled parity for PipelineRunner fallback path (#121) * Initial plan * fix: typed-nil guard, _response_handled fallback, add route pipeline tests Co-authored-by: intel352 <77607+intel352@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: intel352 <77607+intel352@users.noreply.github.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
routePipelinesmapsstring → interfaces.PipelineRunner, so a caller can store a typed-nil*Pipelineas the interface value. The previouspipeline != nilguard passes for typed-nil interfaces, and the subsequent type assertion succeeds yielding a nil pointer — causing a panic onconcretePipeline.Metadata = ….The
Run()fallback for non-*Pipelineimplementations also lacked the_response_handledsentinel check present in the*Pipelinepath, risking double-writes when a custom runner writes directly to theResponseWriter.Changes
Typed-nil guard (
command_handler.go,query_handler.go): Hoist the type assertion before the branch so both cases are covered with a single assertion:_response_handledparity inRun()fallback: Afterpipeline.Run()returns, checkresult["_response_handled"] == trueand skip JSON encoding if set — matching the behaviour of the*Pipelinepath.Tests (
command_handler_test.go,query_handler_test.go): AddedmockPipelineRunner(shared acrosspackage moduletests) and four new cases per handler:_response_handled=truesuppresses the response bodyRun()error yields a 500*Pipelinedoes not panic and falls through to 404💡 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.