Skip to content

fix(console): anonymous GraphQL for rustyWebSearch live path - #202

Open
Travis-Gilbert wants to merge 1 commit into
mainfrom
fix/rustyweb-anonymous-graphql-op
Open

fix(console): anonymous GraphQL for rustyWebSearch live path#202
Travis-Gilbert wants to merge 1 commit into
mainfrom
fix/rustyweb-anonymous-graphql-op

Conversation

@Travis-Gilbert

@Travis-Gilbert Travis-Gilbert commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Drop the named ConsoleRustyWebSearch operation so rustyWebSearch works against commonplace-api builds that return HTTP 400 (empty body) for named ops on that field.
  • Pass method/path/body into credentialHeaders so signed-request custody can sign the GraphQL POST used by indexer / web research.

Why

Local live spine testing showed Console /api/indexer/search failing as web_search_refused / unreachable while direct anonymous GraphQL and node /v1/rustyweb/search returned receipt.mode: spine. Production has Brave/Perplexity/etc. configured; this unblocks the Console → data-api → store path for a live retest on v2.

Test plan

  • Deploy / preview this Console change against production commonplace-api + rustyred-store
  • From signed-in v2 Console, run Indexer (or chat web research) search
  • Confirm upstream search returns non-empty candidates when providers are live (Brave/Perplexity/SearXNG)
  • Confirm GraphQL errors no longer show empty HTTP 400 for this field
  • Spot-check signed-request path still authenticates when custody is configured

Summary by CodeRabbit

  • Bug Fixes
    • Improved web research search request reliability.
    • Enhanced request signing by including the correct request method, path, and body.
    • Added safer handling for endpoint paths and request serialization.

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.
Copilot AI lite review requested due to automatic review settings August 9, 2026 22:38
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The web research GraphQL request is now anonymous. The request body is serialized before sending, the endpoint pathname uses a /graphql fallback, and credential headers receive the POST method, path, and body for signing.

Changes

Web research request

Layer / File(s) Summary
Serialize and sign the GraphQL request
apps/console/src/lib/server/web-research.ts
The RustyWeb query is anonymous. The request serializes its payload, derives a safe pathname, and passes the POST method, pathname, and body to credential header generation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Travis-Gilbert/CommonPlace#136: This PR also modifies web-research.ts, but it focuses on consumer GraphQL migration rather than request serialization and signing.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: using an anonymous GraphQL operation for the console's rustyWebSearch live path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rustyweb-anonymous-graphql-op

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rustyWebSearch GraphQL 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 } into credentialHeaders to 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.

Comment on lines 104 to +109
'Content-Type': 'application/json',
...credentialHeaders(credential.credential),
...credentialHeaders(credential.credential, {
method: 'POST',
path: graphqlPath,
body,
}),

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a76920 and 7955461.

📒 Files selected for processing (1)
  • apps/console/src/lib/server/web-research.ts

Comment on lines +105 to +109
...credentialHeaders(credential.credential, {
method: 'POST',
path: graphqlPath,
body,
}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.ts

Repository: 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 }));
JS

Repository: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants