fix(console): anonymous GraphQL for rustyWebSearch live path - #202
fix(console): anonymous GraphQL for rustyWebSearch live path#202Travis-Gilbert wants to merge 1 commit into
Conversation
Named ConsoleRustyWebSearch operations return HTTP 400 with an empty body on some commonplace-api builds, which made indexer/web research look unreachable. Also pass method/path/body into credentialHeaders so signed-request custody can sign the GraphQL POST.
📝 WalkthroughWalkthroughThe web research GraphQL request is now anonymous. The request body is serialized before sending, the endpoint pathname uses a ChangesWeb research request
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Console’s server-side RustyWeb search GraphQL request to be compatible with commonplace-api builds that reject named operations for rustyWebSearch, and prepares the request metadata for signed-request custody when calling the consumer GraphQL endpoint.
Changes:
- Switch
rustyWebSearchGraphQL document from a named operation to an anonymous operation. - Precompute the GraphQL POST body and derive the request path from the endpoint URL.
- Pass
{ method, path, body }intocredentialHeadersto enable signing of the GraphQL POST.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| 'Content-Type': 'application/json', | ||
| ...credentialHeaders(credential.credential), | ||
| ...credentialHeaders(credential.credential, { | ||
| method: 'POST', | ||
| path: graphqlPath, | ||
| body, | ||
| }), |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/console/src/lib/server/web-research.ts`:
- Around line 105-109: The credentialHeaders call passes request fields
unsupported by its current signature. Update credentialHeaders and its signer
contract to accept and use credential.credential plus method, path, and body, or
replace it with the existing helper that supports signed-request custody while
preserving the generated authentication headers.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b17b9503-4847-44f3-b95c-70e1ba26f37d
📒 Files selected for processing (1)
apps/console/src/lib/server/web-research.ts
| ...credentialHeaders(credential.credential, { | ||
| method: 'POST', | ||
| path: graphqlPath, | ||
| body, | ||
| }), |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Confirm the helper declaration and the changed call.
rg -n -A16 -B3 'export function credentialHeaders' \
apps/console/src/lib/server/upstream-credential.ts
rg -n -A10 -B4 'credentialHeaders\(credential\.credential' \
apps/console/src/lib/server/web-research.tsRepository: Travis-Gilbert/CommonPlace
Length of output: 1228
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "## Candidate files:"
git ls-files | rg '(^|/)src/lib/server/(upstream-credential|web-research)\.ts$' || true
echo
echo "## upstream-credential declarations:"
cat -n apps/console/src/lib/server/upstream-credential.ts | sed -n '1,120p'
echo
echo "## web-research relevant section:"
cat -n apps/console/src/lib/server/web-research.ts | sed -n '80,120p'
echo
echo "## TypeScript type-check behavior for call signature (from file text via tsc if available):"
if command -v tsc >/dev/null 2>&1; then
tsc --noEmit --strict --target es2022 --module esnext --moduleResolution bundler --noImplicitAny false --strictNullChecks true --skipLibCheck false apps/console/src/lib/server/web-research.ts apps/console/src/lib/server/upstream-credential.ts 2>&1 || true
else
echo "tsc not available"
fi
echo
echo "## JavaScript arity observation from installed TypeScript if available:"
node - <<'JS'
function credentialHeaders(credential) {
return { 'x-api-key': credential.key };
}
const result = credentialHeaders(
{ kind: 'service_key', key: 'key1' },
{ method: 'POST', path: '/graphql', body: '{}', credential: { kind: 'service_key', key: 'key1' } }
);
console.log(JSON.stringify({ argumentCount: 2, returnedHeaders: result }));
JSRepository: Travis-Gilbert/CommonPlace
Length of output: 9281
Fix the credentialHeaders call to match its signature.
credentialHeaders is declared with one parameter but this call passes (credential.credential, { method, path, body }), which should fail TypeScript. Update the signer/contract to accept and use these fields, or call a helper that supports signed-request custody.
🤖 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 `@apps/console/src/lib/server/web-research.ts` around lines 105 - 109, The
credentialHeaders call passes request fields unsupported by its current
signature. Update credentialHeaders and its signer contract to accept and use
credential.credential plus method, path, and body, or replace it with the
existing helper that supports signed-request custody while preserving the
generated authentication headers.
Summary
ConsoleRustyWebSearchoperation sorustyWebSearchworks against commonplace-api builds that return HTTP 400 (empty body) for named ops on that field.credentialHeadersso signed-request custody can sign the GraphQL POST used by indexer / web research.Why
Local live spine testing showed Console
/api/indexer/searchfailing asweb_search_refused/ unreachable while direct anonymous GraphQL and node/v1/rustyweb/searchreturnedreceipt.mode: spine. Production has Brave/Perplexity/etc. configured; this unblocks the Console → data-api → store path for a live retest on v2.Test plan
Summary by CodeRabbit