test+fix: address principal-engineer review findings (Phases 0-4)#618
Closed
lakhansamani wants to merge 1 commit into
Closed
test+fix: address principal-engineer review findings (Phases 0-4)#618lakhansamani wants to merge 1 commit into
lakhansamani wants to merge 1 commit into
Conversation
Adds the missing integration/e2e test coverage flagged across reviews of #614 / #615 / #616 / #617, and fixes the blocking bugs those reviews surfaced. Test additions are spread across every layer the PR stack introduces; fixes are deliberately scoped to issues that would have hit production on the first deploy. NEW TESTS internal/parsers/url_test.go - TestGetHostFromRequest: header priority + spoof rejection - TestGetAppURLFromRequest internal/cookie/cookie_test.go - TestBuildSessionCookies: 3 hostname scenarios, validates domain-scoped cookie picks up the apex, MaxAge/Secure/HttpOnly/SameSite all preserved - TestBuildMfaSessionCookies + insecure-Lax-SameSite variant - TestParseSameSite internal/service/sideeffects_test.go - MetaFromGin / ApplyToGin nil-safety + cookie round-trip - ResponseSideEffects.AddCookie nil tolerance internal/grpcsrv/interceptors/interceptors_test.go - Recovery turns panic into codes.Internal; stack stays server-side - Recovery passes normal errors through unchanged - Logging emits info/warn/error at the right thresholds per gRPC code - Validate rejects bad requests (protovalidate enforces email format) - Validate allows valid requests and tolerates non-proto request types internal/grpcsrv/transport/grpc_metadata_test.go - MetaFromGRPC extracts host/IP/UA/auth/cookies; :authority fallback - cookiesFromMetadata parses multi-header cookies - ApplyToGRPC nil-safety internal/mcp/schema_test.go - schemaForMessage for flat scalars + nested message (AppData) - **TestSchemaForMessage_CycleSafe** would have caught the original stack-overflow bug - Documents current oneof flattening as known limitation internal/integration_tests/grpc_surface_test.go - TestGRPCStubsReturnUnimplemented: every one of the 18 stubbed RPCs verified to return codes.Unimplemented (locks down the contract so future migrations can't accidentally regress to OK or panic) - TestGRPCHealthCheckProtocol: grpc.health.v1.Health responds SERVING internal/integration_tests/rest_openapi_test.go - /openapi.json serves valid swagger 2.0 with non-empty paths object internal/integration_tests/mcp_stubs_test.go - MCP call to a stubbed tool returns CallToolResult{IsError:true} with "Unimplemented" in the text (vs the previous JSON-RPC-level error) BLOCKING FIXES FROM REVIEW cmd/root.go - --grpc-port default 8081 collided with --metrics-port. Moved gRPC to 9091. Added a triple-port collision check (HTTP/metrics/gRPC) at startup; fail fast with a specific error message. internal/grpcsrv/transport/grpc_metadata.go - MetaFromGRPC now extracts cookies from grpcgateway-cookie / cookie metadata. The old version silently dropped them, which would have broken every authenticated flow as soon as the SessionService stubs were replaced with real handlers. - ApplyToGRPC now emits ALL Set-Cookie metadata entries via md.Append. The old version sent only the first cookie, breaking the host-scoped + domain-scoped session-cookie pair. internal/mcp/schema.go - schemaForMessage tracks visited descriptors. Without this, exposing any tool whose request contained google.protobuf.Value (e.g. AppData → Struct → Value → repeated Value) would stack-overflow at server boot. Cycle short-circuits to opaque `object`. internal/mcp/server.go - Tool execution errors (gRPC Unimplemented / PermissionDenied / etc.) now surface as CallToolResult{IsError:true} with the gRPC status message — the MCP-spec way to give the LLM actionable text instead of a low-level JSON-RPC failure. - Replaced fragile json-null string compare with strings.TrimSpace+ isJSONNull helper. internal/mcp/scanner.go - Removed unused descriptorOptionsCarrier dead-code struct + always- failing type assertion in mcpToolFromMethod. Function is now what it was always trying to be: 4 lines. internal/server/http_routes.go + gen/openapi/openapi.go - /openapi.json no longer reads via relative path (which broke in Docker / tests where cwd ≠ repo root). The spec is now embedded via go:embed. NOT FIXED IN THIS PR (deferred) - --grpc-tls-cert/-key/-insecure flags are still placeholders. Tracked for a TLS-implementation PR alongside the metrics-listener TLS work. - Secrets in REST path (DELETE /v1/refresh-tokens/{token} etc.) flagged by reviewer; the migration to body-borne tokens is a proto-design change worth its own PR + design discussion. - MCP auth metadata propagation — punted; today's MCP-exposed tools are GetMeta (no auth needed) + 3 stubs. Real wiring lands when those stubs become real handlers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 30, 2026
Closed
Contributor
Author
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.
Summary
Adds the missing integration/e2e test coverage flagged across reviews of #614 / #615 / #616 / #617, and fixes the blocking bugs those reviews surfaced. Test additions are spread across every layer the PR stack introduces; fixes are deliberately scoped to issues that would have hit production on the first deploy.
New tests (8 files, ~50 sub-cases)
Blocking fixes from review
Deliberately deferred (tracked but not in this PR)
Test plan
🤖 Generated with Claude Code