feat: implement ptq rpc and index schemas - #3138
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
WalkthroughThe change adds a ChangesPrompt-to-Query integration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (46.09%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3138 +/- ##
===========================================
- Coverage 62.37% 43.85% -18.52%
===========================================
Files 262 1072 +810
Lines 31003 140577 +109574
Branches 0 7361 +7361
===========================================
+ Hits 19337 61655 +42318
- Misses 10158 77071 +66913
- Partials 1508 1851 +343
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
controlplane/src/core/bufservices/NodeService.ts (1)
71-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd explicit handler types.
Line 71 relies on contextual types for
reqandctx. Add explicit parameter types and a return type forgenerateQuery.As per coding guidelines, use explicit type annotations for function parameters and return types in TypeScript.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@controlplane/src/core/bufservices/NodeService.ts` at line 71, Update the generateQuery method signature in NodeService to add explicit TypeScript types for both req and ctx parameters and its return type, using the existing request, context, and response types established by the service rather than relying on contextual inference.Source: Coding guidelines
controlplane/src/core/services/PromptToQueryService.ts (1)
135-135: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDeclare the return type.
Add
: Promise<void>toindexSchema.As per coding guidelines, “Use explicit type annotations for function parameters and return types in TypeScript.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@controlplane/src/core/services/PromptToQueryService.ts` at line 135, Update the PromptToQueryService.indexSchema method to include an explicit return type annotation of Promise<void>. Keep the existing async behavior and implementation unchanged, and apply the annotation directly on indexSchema so it matches the TypeScript return-type guideline.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@controlplane/src/core/bufservices/NodeService.ts`:
- Line 85: Update the request flow in NodeService around
ptqService.generateQuery to resolve the requested schemaHash against
authContext.federatedGraphId and authContext.organizationId, authorize that
association, and pass only the validated graph-bound hash to
PromptToQueryService instead of forwarding the caller-controlled value directly.
In `@controlplane/src/core/env.schema.ts`:
- Around line 233-236: Update the PROMPT_TO_QUERY_SERVICE_ENDPOINT schema
definition in env.schema.ts to accept only HTTPS URLs, replacing the current
generic URL validation while preserving its optional behavior.
In `@controlplane/src/core/services/PromptToQueryService.ts`:
- Line 113: Remove the unconditional console.log call in PromptToQueryService’s
response-parsing flow. Do not emit parser output for valid responses; if logging
invalid-response details is required, route it through this.logger with
controlled failure metadata instead.
---
Nitpick comments:
In `@controlplane/src/core/bufservices/NodeService.ts`:
- Line 71: Update the generateQuery method signature in NodeService to add
explicit TypeScript types for both req and ctx parameters and its return type,
using the existing request, context, and response types established by the
service rather than relying on contextual inference.
In `@controlplane/src/core/services/PromptToQueryService.ts`:
- Line 135: Update the PromptToQueryService.indexSchema method to include an
explicit return type annotation of Promise<void>. Keep the existing async
behavior and implementation unchanged, and apply the annotation directly on
indexSchema so it matches the TypeScript return-type guideline.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a20cbab0-fe77-48fa-8838-9ce1ba16ccb2
⛔ Files ignored due to path filters (4)
connect-go/gen/proto/wg/cosmo/node/v1/node.pb.gois excluded by!**/*.pb.go,!**/gen/**connect-go/gen/proto/wg/cosmo/node/v1/nodev1connect/node.connect.gois excluded by!**/gen/**router/gen/proto/wg/cosmo/node/v1/node.pb.gois excluded by!**/*.pb.go,!**/gen/**router/gen/proto/wg/cosmo/node/v1/nodev1connect/node.connect.gois excluded by!**/gen/**
📒 Files selected for processing (34)
connect/src/wg/cosmo/node/v1/node-NodeService_connectquery.tsconnect/src/wg/cosmo/node/v1/node_pb.tscontrolplane/.env.examplecontrolplane/src/core/bufservices/NodeService.tscontrolplane/src/core/bufservices/contract/createContract.tscontrolplane/src/core/bufservices/contract/updateContract.tscontrolplane/src/core/bufservices/feature-flag/createFeatureFlag.tscontrolplane/src/core/bufservices/feature-flag/deleteFeatureFlag.tscontrolplane/src/core/bufservices/feature-flag/enableFeatureFlag.tscontrolplane/src/core/bufservices/feature-flag/recomposeFeatureFlag.tscontrolplane/src/core/bufservices/feature-flag/updateFeatureFlag.tscontrolplane/src/core/bufservices/federated-graph/createFederatedGraph.tscontrolplane/src/core/bufservices/federated-graph/migrateFromApollo.tscontrolplane/src/core/bufservices/federated-graph/moveFederatedGraph.tscontrolplane/src/core/bufservices/federated-graph/updateFederatedGraph.tscontrolplane/src/core/bufservices/graph/recomposeGraph.tscontrolplane/src/core/bufservices/graph/setGraphRouterCompatibilityVersion.tscontrolplane/src/core/bufservices/monograph/publishMonograph.tscontrolplane/src/core/bufservices/monograph/updateMonograph.tscontrolplane/src/core/bufservices/subgraph/deleteFederatedSubgraph.tscontrolplane/src/core/bufservices/subgraph/moveSubgraph.tscontrolplane/src/core/bufservices/subgraph/publishFederatedSubgraph.tscontrolplane/src/core/bufservices/subgraph/publishFederatedSubgraphs.tscontrolplane/src/core/bufservices/subgraph/updateSubgraph.tscontrolplane/src/core/build-server.tscontrolplane/src/core/composition/composer.tscontrolplane/src/core/env.schema.tscontrolplane/src/core/repositories/OrganizationRepository.tscontrolplane/src/core/routes.tscontrolplane/src/core/services/CompositionService.tscontrolplane/src/core/services/PromptToQueryService.tscontrolplane/src/index.tscontrolplane/src/types/index.tsproto/wg/cosmo/node/v1/node.proto
| opts.billingDefaultPlanId, | ||
| ); | ||
|
|
||
| return ptqService.generateQuery(req.schemaHash, req.prompt); |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline controlplane/src/core/bufservices/NodeService.ts --items all
rg -n -C 5 'schemaHash|schemaSha|indexId|EnsureIndex|indexSchema|GenerateQuery' controlplane connect proto
rg -n -C 5 'authenticateRouter|federatedGraphId|organizationId' controlplane/srcRepository: wundergraph/cosmo
Length of output: 50374
Authorization Bypass (CWE-639): Authorization Bypass Through User-Controlled Key (IDOR)
Reachability: External · Exploitability: Moderate
Reachability path
● Entry
connect/src/wg/cosmo/node/v1/node-NodeService_connectquery.ts:15
generateQuery
│
▼
● Sink
controlplane/src/core/bufservices/NodeService.ts
Bind schemaHash to the authenticated router graph.
generateQuery scopes only the feature check to authContext.organizationId and forwards the caller-controlled hash as indexId. Resolve and authorize the hash for authContext.federatedGraphId and authContext.organizationId before calling PromptToQueryService.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@controlplane/src/core/bufservices/NodeService.ts` at line 85, Update the
request flow in NodeService around ptqService.generateQuery to resolve the
requested schemaHash against authContext.federatedGraphId and
authContext.organizationId, authorize that association, and pass only the
validated graph-bound hash to PromptToQueryService instead of forwarding the
caller-controlled value directly.
| /** | ||
| * Prompt-to-Query | ||
| */ | ||
| PROMPT_TO_QUERY_SERVICE_ENDPOINT: z.string().url().optional(), |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- references ---'
rg -n -C 5 --glob '!node_modules' --glob '!dist' --glob '!build' \
'PROMPT_TO_QUERY_SERVICE_ENDPOINT|Prompt.?to.?Query|prompt.?to.?query' .
printf '%s\n' '--- candidate files ---'
git ls-files | rg -i 'prompt|query|env|docker|helm|kubernetes|compose|deployment|readme|config' | head -200Repository: wundergraph/cosmo
Length of output: 19182
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- PromptToQueryService structure ---'
ast-grep outline controlplane/src/core/services/PromptToQueryService.ts
printf '%s\n' '--- service implementation ---'
sed -n '1,190p' controlplane/src/core/services/PromptToQueryService.ts
printf '%s\n' '--- HTTP client and promptToQuery wiring ---'
rg -n -C 8 --glob '*.ts' --glob '*.tsx' \
'promptToQuery|serviceAddress|httpClient|GenerateQuery|YokoService' controlplane/src
printf '%s\n' '--- configuration examples and deployment references ---'
rg -n -C 6 --glob '!node_modules' --glob '!dist' --glob '!build' \
'PROMPT_TO_QUERY_SERVICE_ENDPOINT|prompt-to-query|Prompt To Query' \
controlplane docker docker-compose.yml docker-compose.full.yml docker-compose.cosmo.yml \
.github docs-website 2>/dev/null || trueRepository: wundergraph/cosmo
Length of output: 50374
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- exact endpoint configuration references ---'
rg -n -C 8 --glob '!node_modules' --glob '!dist' --glob '!build' \
'PROMPT_TO_QUERY_SERVICE_ENDPOINT' controlplane .github docs-website docker docker-compose.yml docker-compose.full.yml docker-compose.cosmo.yml
printf '%s\n' '--- PTQ method callers and request entry points ---'
rg -n -C 6 --glob '*.ts' --glob '*.tsx' \
'\.generateQuery\(|generateQuery\(|\.indexSchema\(|indexSchema\(' controlplane/src
printf '%s\n' '--- deployment transport controls near controlplane configuration ---'
rg -n -C 5 --glob '*.yaml' --glob '*.yml' --glob '*.md' --glob '*.env.example' \
'PROMPT_TO_QUERY|controlplane.*(url|host)|https://|http://' \
.github docs-website controlplane docker docker-compose.yml docker-compose.full.yml docker-compose.cosmo.yml 2>/dev/null | head -300Repository: wundergraph/cosmo
Length of output: 29384
Security Misconfiguration (CWE-319): Cleartext Transmission of Sensitive Information
Reachability: Internal
Reachability path
● Entry
controlplane/src/index.ts:83
envVariables
│
▼
● Sink
controlplane/src/core/env.schema.ts
Require HTTPS for PROMPT_TO_QUERY_SERVICE_ENDPOINT.
The PTQ client sends prompts and schema data through Axios. The schema accepts http://, which can expose this data on untrusted networks. Require HTTPS or enforce a private, authenticated network boundary.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@controlplane/src/core/env.schema.ts` around lines 233 - 236, Update the
PROMPT_TO_QUERY_SERVICE_ENDPOINT schema definition in env.schema.ts to accept
only HTTPS URLs, replacing the current generic URL validation while preserving
its optional behavior.
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Summary by CodeRabbit
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.