Comments (21)
I was having the same problem.
Apparently it is caused by missing permission on service account executing cloud function.
I just added Storage Object Admin
role to default to default service account and everything start to work as expected.
from functions-samples.
For posterity: Cloud Functions requires editor permission on your project.
from functions-samples.
FYI this issue is somewhat widespread because we used to have a bug (as of 1-2 month ago) where lots of Cloud Storage Buckets were created with the wrong permissions. New projects don't have this issue but if you have an old Firebase project which is impacted by this the manual fix for your permissions is described here:
firebase/codelab-friendlychat-web#184 (comment)
from functions-samples.
Can you tell us a bit more about when the deploy error happens? Is that when you are running the CLI firebase deploy
? Can you copy paste the full output off the CLI?
from functions-samples.
Exactly, during deployment process. I've searching more about this, and it seems we need to have billing enabled and firebase store and google cloud store are two different products. My understanding was that the image resizing function works on firebase store which apparently is not correct. My use case is, when someone uploads file to firebase store (using firebase client) I want to resize image using cloud function. Could you please clarify if that's possible?
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (2.63 KB) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: updating function addTag...
i functions: updating function adjustments...
i functions: updating function generateThumbnail...
⚠ functions[generateThumbnail]: Deploy Error: Failed to configure trigger GCS Bucket: product_images
✔ functions[addTag]: Successful update operation.
✔ functions[adjustments]: Successful update operation.
✔ functions: 2 function(s) deployed successfully.
from functions-samples.
Can you change:
exports.generateThumbnail = functions.storage.bucket().object().onChange(event => {
to:
exports.generateThumbnail = functions.storage.object().onChange(event => {
?
It looks like Functions thinks you want a trigger on the bucket named product_images
which would happened if your code was:
exports.generateThumbnail = functions.storage.bucket('product_images').object().onChange(event => {
Even if that works, could you paste what you have in your code above so we can investigate?
from functions-samples.
This is what I have, same as you suggested.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const gcs = require('@google-cloud/storage')();
const spawn = require('child-process-promise').spawn;
exports.generateThumbnail = functions.storage.object().onChange(event => {
const object = event.data;
const fileBucket = object.bucket;
const filePath = object.name;
const contentType = object.contentType;
const resourceState = object.resourceState;
if(!filePath.match(/product_images/)) {
console.log('not product_images bucket');
return;
}
if (!contentType.startsWith('image/')) {
console.log('This is not an image.');
return;
}
const fileName = filePath.split('/').pop();
// Exit if the image is already a thumbnail.
if (fileName.startsWith('thumb_')) {
console.log('Already a Thumbnail.');
return;
}
if (resourceState === 'not_exists') {
console.log('This is a deletion event.');
return;
}
const bucket = gcs.bucket(fileBucket);
const tempFilePath = `/tmp/${fileName}`;
return bucket.file(filePath).download({
destination: tempFilePath
}).then(() => {
console.log('Image downloaded locally to', tempFilePath);
// Generate a thumbnail using ImageMagick.
return spawn('convert', [tempFilePath, '-thumbnail', '64x64>', tempFilePath]).then(() => {
console.log('Thumbnail created at', tempFilePath);
// We add a 'thumb_' prefix to thumbnails file name. That's where we'll upload the thumbnail.
const thumbFilePath = filePath.replace(/(\/)?([^\/]*)$/, `$1thumb_$2`);
// Uploading the thumbnail.
return bucket.upload(tempFilePath, {
destination: thumbFilePath
});
});
});
});
from functions-samples.
This looks like it's a backend issue. I can investigate; do we have permission to view logs related to your account?
from functions-samples.
@inlined Sure! Let me know if anything is required.
from functions-samples.
I found a stack trace in our backend; since this conversation includes details about your personal app I'm going to reach out to you at the email address listed on your GitHub profile.
from functions-samples.
Yes @inlined mailed me with details. I'm guessing the particular project I was working on was affected by the bug. It worked fine with a new project.
from functions-samples.
Glak you got it sorted @amitava82 !
I'm changing the title and added the comment above so that it's easier to find for other developers that might be infected.
from functions-samples.
Just had this happen with a Realtime Database trigger for firebase. Should I report as bug? Trigger has not been edited and has worked previously.
from functions-samples.
Please contact support directly. GitHub bugs are for bugs with the SDK.
from functions-samples.
@inlined I am getting this exact same issue. Would you mind having a look for me?
https://stackoverflow.com/questions/48901888/firebase-storage-trigger-not-working
from functions-samples.
I'm having the same issue.
I'm deploying a function and getting Failed to configure trigger GCS Bucket
.
I'm declaring the function as required per the docs:
functions.storage.object().onFinalize((object) => {...})
This exact same function deploys ok on another project.
Edit:
I've created a new Firebase project and tried to deploy with the same error.
I've contacted Firebase support but I need to solve this ASAP and these guys are usually quite slow.
from functions-samples.
I have added permission but still not working for me
from functions-samples.
I started receiving these messages as well with a newly created firebase project. It was working previously with my old project.
from functions-samples.
Same for me. I've tried everything I could find online (changing IAM, adding roles, updating permissions...) but the deploy won't work. Even with a new project. My other project (created a year ago) works fine though...
from functions-samples.
@peterwarbo I haven't changed a thing and now it works for me. Could you try again ?
from functions-samples.
@mparpaillon ah, will try again. Maybe it was a temporary outage with storage 😊
from functions-samples.
Related Issues (20)
- [BUG] in sample: alert
- DisplayUnlockCaptcha
- [BUG] in sample:
- [DOCS] for sample: taskqueues-backup-images, it simply doesn't work with tasks_fn.on_task_dispatched function, only with http_fn.on_request function HOT 5
- onTaskDispatched when region is set the function don't deploy to the region in sample:
- [BUG] Some phone numbers do not receive OTP SMS messages with Firebase phone auth: HOT 5
- Problems with sending push notifications
- functions predeploy error: Command terminated with non-zero exit code 2 HOT 1
- functions predeploy error: Command terminated with non-zero exit code 2 HOT 1
- [DOCS] for sample: python callable functions
- How is this still a problem 2 years later? I am running into this now.
- [BUG] in sample: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/v2/providers/scheduler' is not defined HOT 1
- [BUG] in sample:
- [DOCS] for sample: auth-blocking-functions | Cannot extract event_type HOT 1
- [DOCS] for sample: monitor-cloud-logging
- [BUG] Firebase Functions Tasks: Firebase ID token has incorrect "aud" (audience) claim. HOT 2
- https_fn.HttpsError::message isn't really surfaced
- ##https://github.com/firebase/functions-samples/tree/d8ec6aa2263e5403b05a33b0a06e9340f6b4968e/quickstarts HOT 1
- Hey-c6fc3 ____firebase app HOT 1
- [BUG] in sample: taskqueues-backup-images HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functions-samples.