firebase / firebase/functions-samples

[BUG] in sample: taskqueues-backup-images

Open
#1,143 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
12.2k
Forks
3.8k
Avg merge
1d 23h
Merged PRs (30d)
2

Description

### Which sample has a bug?

https://github.com/firebase/functions-samples/blob/703c0359eacf07a551751d1319d34f912a2cd828/Node/taskqueues-backup-images/functions/index.js#L115-L132

### How to reproduce the issue

Used `getFunctionUrl` exactly as shown.

**Steps to set up and reproduce**

Attempt to queue a function using the code shown. EG:
```ts
const queue = getFunctions().taskQueue("reminderEmail");
const targetUrl = await getFunctionUrl("reminderEmail");

queue.enqueue({bookingRequestId: event.params.docId}, {
scheduleTime: new Date(),
uri: targetUrl,
}).then(() => {
console.log(`Queued reminder email for ${date}.`);
});
```

### Debug output

| | |
| --- | --- |
| Status code | 7 (PERMISSION_DENIED) |
| Reason to retry | PERMISSION_DENIED(7): HTTP status code 403 |

SCR-20240621-nrfl

### Expected behavior

The function runs successfully. The documentation states,

> Due to the way Cloud Tasks creates authentication tokens to authenticate requests to the underlying task queue functions, you must specify the Cloud Run URL of the function when enqueuing tasks. We recommend that you programmatically retrieve the URL for your function as demonstrated below...

However, the uri itself does not seem sufficient to authenticate the cloud function.

### Actual behavior

The function is missing the necessary authentication.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.