Description
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
What did you do?
My SCW config is configured to work with multi-profiles.
Example:
# /Users/$USER/.config/scw/config.yaml
active_profile: profile2
profiles:
profile1:
access_key: ACCESS_KEY
secret_key: SECRET_KEY
default_organization_id: DEFAULT_ORGANIZATION_ID
default_project_id: DEFAULT_PROJECT_ID
default_zone: fr-par-1
default_region: fr-par
api_url: https://api.scaleway.com
insecure: false
profile2:
access_key: ACCESS_KEY
secret_key: SECRET_KEY
default_organization_id: DEFAULT_ORGANIZATION_ID
default_project_id: DEFAULT_PROJECT_ID
default_zone: fr-par-1
default_region: fr-par
I set up the current profile using $ scw config profile activate profile2
I followed the getting started doc to deploy the go-func example. When deploying the function an error occured, stacktrace :
Environment: darwin, node 22.13.1, framework 3.39.0, plugin 7.2.3, SDK 4.5.1
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
TypeError: Cannot read properties of undefined (reading 'length')
at ScalewayDeploy.validateCredentials (/Users/<...>/go-func/node_modules/serverless-scaleway-functions/shared/validate.js:66:32)
at ScalewayDeploy.tryCatcher (/Users/<...>/go-func/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/<...>/go-func/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/<...>/go-func/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/<...>/go-func/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/<...>/go-func/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/<...>/go-func/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/<...>/go-func/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/<...>/go-func/node_modules/bluebird/js/release/async.js:102:5)
at Async.drainQueues (/Users/<...>/go-func/node_modules/bluebird/js/release/async.js:15:14)
at process.processImmediate (node:internal/timers:491:21)
What did you expect to see?
I expect the serverless deploy to automatically use my current SCW profile
What did you see instead?
An error
What version of Node are you using (node --version
)?
$ node --version
> v22.13.1
Does this issue reproduce with the latest release?
Yes
Additional information
I found out the reason in the validate.js file by adding
# serverless-scaleway-functions/shared/validate.js
this.provider.scwToken === undefined ||
this.provider.getScwProject() === undefined ||
this.provider.scwToken.length !== 36 ||
this.provider.getScwProject().length !== 36
I can open a PR if you are interested, see the new error which is easier to understand :
Error: Error: Either "scwToken" or "scwProject" is invalid. Credentials to deploy on your Scaleway Account are required, please read the documentation.
Furthermore, I fixed it by adding the token and project_id in the serverless.yml
file of the target profile.
# serverless.yml
service: go-func
configValidationMode: off
provider:
name: scaleway
runtime: go122 # Available go runtimes are listed in documentation
# Global Environment variables - used in every functions
env:
test: test
scwToken: SCW_TOKEN
scwProject: SCW_PROJECT
scwRegion: fr-par
Is there a "profile" key in serverless.yml
to define the profile to use ?