Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output helpful error message when the project ID was not found #2282

Open
dandv opened this issue Jan 8, 2025 · 0 comments
Open

Output helpful error message when the project ID was not found #2282

dandv opened this issue Jan 8, 2025 · 0 comments
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@dandv
Copy link

dandv commented Jan 8, 2025

Environment details

  • OS: Linux
  • Node.js version: 22
  • npm version: 11
  • @google-cloud/firestore version:

Steps to reproduce

When running the script below,

import { initializeApp, cert } from 'firebase-admin/app';
import { getFirestore } from 'firebase-admin/firestore';

// Connect to the Firestore emulator of project specified by its ID
Deno.env.set('FIRESTORE_EMULATOR_HOST', '127.0.0.1:8080');
initializeApp({
    projectId: 'onDocumentCreated',  // typo, should be kebab case
});
const db = getFirestore();
console.log('DB obtained');

const docs = await db.collection('docs').get();  // fails with `Error: 2 UNKNOWN: `
console.log('DB request succeeded');

Firestore fails with an unhelpful error message if the projectId was incorrect. When this is obtained via an entire cascade of environment variables and tool executions, a useful error message would really help.

$ deno -A wrong-projectId-error.mjs 
DB obtained
error: Uncaught (in promise) Error: 2 UNKNOWN: 
$ node wrong-projectId-error.mjs 
DB obtained
(node:216835) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
node:internal/modules/run_main:122
    triggerUncaughtException(
    ^

Error: 2 UNKNOWN: 
    at callErrorFromStatus (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@grpc/grpc-js/build/src/client.js:359:73)
    at Object.onReceiveStatus (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at /home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@grpc/grpc-js/build/src/resolving-call.js:129:78
    at process.processTicksAndRejections (node:internal/process/task_queues:85:11)
for call at
    at ServiceClientImpl.makeServerStreamRequest (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@grpc/grpc-js/build/src/client.js:342:32)
    at ServiceClientImpl.<anonymous> (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at /home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:237:29
    at /home/dandv/bugs/node_modules/.deno/[email protected]/node_modules/google-gax/build/src/streamingCalls/streamingApiCaller.js:38:28
    at /home/dandv/bugs/node_modules/.deno/[email protected]/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
    at Object.request (/home/dandv/bugs/node_modules/.deno/[email protected]/node_modules/google-gax/build/src/streamingCalls/streaming.js:376:40)
    at Timeout.makeRequest [as _onTimeout] (/home/dandv/bugs/node_modules/.deno/[email protected]/node_modules/retry-request/index.js:159:28)
    at listOnTimeout (node:internal/timers:594:17)
    at process.processTimers (node:internal/timers:529:7)
Caused by: Error
    at QueryUtil._getResponse (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@google-cloud/firestore/build/src/reference/query-util.js:44:23)
    at CollectionReference._getResponse (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@google-cloud/firestore/build/src/reference/query.js:784:32)
    at CollectionReference._get (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@google-cloud/firestore/build/src/reference/query.js:777:35)
    at /home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@google-cloud/firestore/build/src/reference/query.js:745:43
    at /home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@google-cloud/firestore/build/src/telemetry/enabled-trace-util.js:110:30
    at NoopContextManager.with (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:25:19)
    at ContextAPI.with (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)
    at NoopTracer.startActiveSpan (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js:65:31)
    at ProxyTracer.startActiveSpan (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js:36:24)
    at EnabledTraceUtil.startActiveSpan (/home/dandv/bugs/node_modules/.deno/@[email protected]/node_modules/@google-cloud/firestore/build/src/telemetry/enabled-trace-util.js:102:28) {
  code: 2,
  details: '',
  metadata: Metadata {
    internalRepr: Map(1) { 'content-type' => [ 'application/grpc' ] },
    options: {}
  }
}

Node.js v22.12.0
@dandv dandv added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 8, 2025
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Jan 8, 2025
@ehsannas ehsannas self-assigned this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants