test: add credential-gated Pinecone integration test - #74
test: add credential-gated Pinecone integration test#74pinecone-groundskeeper[bot] wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b57c29. Configure here.
| if (indexCreated) { | ||
| await pinecone.deleteIndex(indexName); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Throwaway indexes can leak
Medium Severity
indexCreated flips only after createIndex with waitUntilReady resolves, and teardown runs only in afterAll. A hook timeout or a cancelled CI job (this workflow uses cancel-in-progress) leaves the live recommender-it-* index behind, which can exhaust the project index quota and fail later creates.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 5b57c29. Configure here.


Problem
The suite under
tests/is unit-only — every Pinecone call is mocked (seetests/chunkedUpsert.test.ts). Nothing exercises a real upsert/query round-trip through the SDK, which is exactly the kind of gap that let a v2→v8 response-shape mismatch (#5) ship undetected: a unit test can't catch a wire-format change, only a real call can.Solution
Added
tests/integration/pinecone.test.ts:describe.skipIf(!process.env.PINECONE_API_KEY), so it's a clean no-op without credentials.recommender-it-<8 hex chars>), usingPINECONE_CLOUD/PINECONE_REGIONfor the spec, matching the pattern already used insrc/index.ts.chunkedUpsertpath (the same helpersrc/index.tsuses), then queries and asserts on the returned records' shape (id, 384-length values, metadata).afterAll, gated on creation having actually succeeded, so a failedbeforeAlldoesn't throw again on cleanup.Kept this off the default
npm testpath so it can never accidentally run credentialed or uncredentialed inside a PR:vitest.config.tsnow excludestests/integration/**explicitly (spread onto vitest's ownconfigDefaults.excluderather than replacing it).vitest.integration.config.tsscopes totests/integration/**/*.test.tswith a 120s test/hook timeout (serverless index creation is slow).npm run test:integrationscript runs that config.ci.ymlgets aworkflow_dispatchtrigger and a newintegration-testjob gatedif: github.event_name != 'pull_request'(push to main or manual dispatch only — a fork PR must never get access toPINECONE_API_KEY). The job passesPINECONE_API_KEY/PINECONE_CLOUD/PINECONE_REGIONfrom secrets; if those secrets aren't configured yet the test's ownskipIfmakes the job a harmless no-op rather than a failure.User impact
Before:
npm testonly ever touches mocks; a real SDK regression is invisible until someone runsnpm run index/npm run recommendby hand.After:
npm run test:integration(and CI'sintegration-testjob, oncePINECONE_API_KEY/PINECONE_CLOUD/PINECONE_REGIONsecrets exist on this repo) actually round-trips a vector through a live index.npm testis unaffected — still 5 files / 23 tests, no network.Follow-ups
PINECONE_API_KEY/PINECONE_CLOUD/PINECONE_REGIONconfigured as Actions secrets (out of my reach — that's a repo-settings change a human needs to make). Until thenintegration-testruns but skips.Verification
npm run typecheck— clean.npm run lint/npm run format:check— clean.npm test— 5 files, 23 tests, unchanged; integration file untouched.npx vitest run -c vitest.integration.config.ts— 1 test, 1 skipped (noPINECONE_API_KEYin this sandbox), confirming the self-skip path works.integration-testCI job will run it for real.Closes #25
Note
Low Risk
Changes are test and CI-only with PR/fork secret isolation and self-skip when credentials are absent; no production runtime paths are modified.
Overview
Adds a live Pinecone upsert/query check so SDK/wire-format regressions are not limited to mocked unit tests. A new
tests/integration/pinecone.test.tscreates a throwaway serverless index, runschunkedUpsertwith real records, polls until queries see the upserts, and asserts match shape (id, vector length, metadata).Default
npm teststays offline:vitest.config.tsexcludestests/integration/**, andnpm run test:integrationuses newvitest.integration.config.ts(longer timeouts).CI gains
workflow_dispatchand anintegration-testjob that runs only on push to main or manual dispatch (never onpull_request), injectingPINECONE_*secrets. The suite **skipIf**s when the API key is missing so missing secrets do not fail the job.Reviewed by Cursor Bugbot for commit 5b57c29. Bugbot is set up for automated code reviews on this repo. Configure here.