firebase / firebase-admin-node

Firebase Admin Node.js SDK

Home Page:https://firebase.google.com/docs/admin/setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getDownloadURL suddenly stopped worked (ApiError: Invalid HTTP method/URL pair.)

NathanC opened this issue · comments

[REQUIRED] Step 2: Describe your environment

  • Operating System version: unsure (deployed in firebase cloud function)
  • Firebase SDK version: 11.11.0
  • Firebase Product: firebase-admin/storage
  • Node.js version: 18
  • NPM version: n/a (yarn)

[REQUIRED] Step 3: Describe the problem

I'm using the new getDownloadUrl function, and it's been working fine. Today, I suddenly started getting an internal error to @google-cloud/storage and it's been very persistent.

ApiError: Invalid HTTP method/URL pair.
    at new ApiError (/workspace/node_modules/@google-cloud/storage/build/src/nodejs-common/util.js:80:15)
    at Util.parseHttpRespBody (/workspace/node_modules/@google-cloud/storage/build/src/nodejs-common/util.js:215:38)
    at Util.handleResp (/workspace/node_modules/@google-cloud/storage/build/src/nodejs-common/util.js:156:117)
    at /workspace/node_modules/@google-cloud/storage/build/src/nodejs-common/util.js:538:22
    at onResponse (/workspace/node_modules/retry-request/index.js:240:7)
    at /workspace/node_modules/teeny-request/build/src/index.js:226:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {

Additional logging shows that something is returning 400 when I try to invoke getDownloadUrl:

 statusCode: 400,
    statusMessage: 'Bad Request',
    request: {
      agent: [Agent],
      headers: [Object],
      href: 'https://firebasestorage.googleapis.com/v0/b/buckets/[redacted: my project].appspot.com/o/[redacted: my file path, properly url encoded]'
    },
    body: '{\n' +
      '  "error": {\n' +
      '    "code": 400,\n' +
      '    "message": "Invalid HTTP method/URL pair."\n' +
      '  }\n' +
      '}',

This was happening on 11.10, and I just updated to 11.11 and it's still present. If I run this from within the functions shell (as opposed to running on my deployed cloud function) it seems to work.

I noticed there's a PR to move to v7 of @google-cloud/storage, maybe that's somehow relevant.

From what I can tell, I didn't introduce any changes (or relevant dependency changes) before the error starts happening. I have a hunch it's environmental in firebase cloud functions.

Steps to reproduce:

const file = storage().bucket().file(path)
await getDownloadURL(imageFile)

Relevant Code:

import { storage } from "firebase-admin";
import { getDownloadURL } from "firebase-admin/storage";

const file = storage().bucket().file(path)
await getDownloadURL(imageFile)

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Hi @NathanC, Thank you for reporting this issue. The issue you are facing could be related to #2318, which should be resolved by now. Please let us know if you continue to experience issues with the API. We are sorry for the frustration this may have caused and thank you for your patience!

@lahirumaramba I just tried again a minute ago, and the issue is still present.

I did get another function failing with a different but similar API error, so I think you're right about this being related to the outage.

Please keep me updated, this is currently blocking a critical flow.

@lahirumaramba just did another test and it's still down. Do you have any additional information?

This just popped up in production, but I was able to workaround it by invoking my cloud function from my local firebase functions:shell. Which seems to imply that it's an issue on the network layer, from making this call where the cloud functions are actually hosted.

This seems to be fixed now. Any post-mortem on the incident would be appreciated.

The quick postmortem is: an internal change to how default bucket name is fetched resulted in a bug where the name was prefixed with buckets/. We are adding new internal integration test to cover this area to avoid similar issues in future.

Hello! I'm getting this error now with "firebase-admin": "11.11.0".
Is there a way to make it work, or maybe I doing anything wrong? Because I see in comments that this issue is fixed. The scenario and the error are exactly matching the one in the root message. Thanks in advance.