Skip to content

[Bug] google_search tool returns 404 — uses 'unknown' projectId instead of ensureProjectContext() #455

@rich-jojo

Description

@rich-jojo

Pre-submission checklist

  • I have searched existing issues for duplicates
  • I have read the Troubleshooting Guide
  • I have read the README installation instructions

Model used

Not applicable (this affects the google_search tool, not model completions)

Exact error message

404 Not Found
Resource projects/unknown could not be found.

Bug description

The google_search tool injected by the plugin always returns a 404 Not Found error because it resolves the project ID using a bare parseRefreshParts() fallback chain that falls through to the literal string "unknown".

Root cause in plugin.js:1115:

const parts = parseRefreshParts(auth.refresh);
const projectId = parts.managedProjectId || parts.projectId || "unknown";

When an account has no managedProjectId or projectId stored in the refresh token metadata (which is common for accounts that haven't completed the managed-project provisioning flow), this resolves to "unknown", and the subsequent API call to v1internal:generateContent with project: "unknown" returns 404.

Contrast with model request path: The model request path uses ensureProjectContext() (in project.js:157) which handles the same situation correctly by:

  1. Checking parts.managedProjectId
  2. Falling back to ANTIGRAVITY_DEFAULT_PROJECT_ID
  3. Attempting to load/provision a managed project via the API
  4. Falling back gracefully to parts.projectId or the default project ID

The google_search tool skips all of this and just uses "unknown".

Steps to reproduce

  1. Install opencode-antigravity-auth@1.5.1
  2. Authenticate with opencode auth login (one Google account)
  3. In a session, invoke the google_search tool with any query
  4. Observe 404 error: Resource projects/unknown could not be found

Suggested fix

Replace the bare parseRefreshParts + || "unknown" pattern in the google_search tool with ensureProjectContext(), matching how model requests resolve the project ID:

// Current (broken):
const parts = parseRefreshParts(auth.refresh);
const projectId = parts.managedProjectId || parts.projectId || "unknown";

// Suggested fix:
const { effectiveProjectId } = await ensureProjectContext(auth);
const projectId = effectiveProjectId;

This would make the search tool use the same robust project resolution logic (including auto-provisioning and default fallback) that model requests already use successfully.

Did this ever work?

Not sure — it may have worked for accounts that already had managedProjectId populated. For accounts without it, this has likely always been broken.

Number of Google accounts configured

1

Reproducibility

Always (100%)

Plugin version

1.5.1

OpenCode version

0.0.0-fix/sse-reconnect-refresh-202602171124

Operating System

Ubuntu 24.04.3 LTS (Linux 6.17.0-14-generic x86_64)

Node.js version

v20.20.0

Environment type

Standard (native terminal) — running as a systemd service

Debug logs

No antigravity-logs directory is created by default. The error is observable from the tool's return value: Search Error: Failed to execute search: 404 Not Found with body containing Resource projects/unknown could not be found.

Relevant source locations (v1.5.1):

  • dist/src/plugin.js:1114-1115 — bare parseRefreshParts + || "unknown"
  • dist/src/plugin/search.js:150project: projectId sent in request body
  • dist/src/plugin/project.js:157ensureProjectContext() (correct path, not used by search)

Compliance

  • I'm using this plugin for personal development only
  • This issue is not related to commercial use or TOS violations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions