serverless / serverless

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.
https://serverless.com
MIT License
46.67k stars 5.74k forks source link

Authentication error with v4.7.0 and node v22.13.1 #13029

Closed CirrusHQ-Pipeline-User closed 2 weeks ago

CirrusHQ-Pipeline-User commented 1 month ago

Issue description

Despite providing the SERVERLESS_ACCESS_KEY as an environmental variable for the serverless. When attempting to package my serverless, I encounter the following error message.

[Container] 2025/03/04 00:30:35.572651 Running command serverless package --stage ${Environment} --region ${AWS_REGION}

✖ Error: Unauthorized at Authentication.getClientDataFromAccessKey (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1159:18340) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Authentication.getAuthenticatedData (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1159:239) at async Authentication.authenticate (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1159:21826) at async TraditionalRunner.resolveVariablesAndAuthenticate (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1177:2379) at async TraditionalRunner.run (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1463:27948) at async route (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1509:2779) at async Object.run (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1510:3668) at async run2 (file:///root/.serverless/releases/4.7.0/package/dist/sf-core.js:1510:4821)

For help, try the following: • Run the command again with the "--debug" option • Run "serverless support" • Review the docs: https://www.serverless.com/framework/docs/

Context

After running the debug command it provides no further context as to why the authentication has failed, just that it has.

CirrusHQ-Pipeline-User commented 1 month ago

Debug flag output:

serverless package --stage stg --region eu-west-1 --debug

s:core: {
  node: 'v22.13.1',
  os: 'linux',
  arch: 'x64',
  shell: '/bin/bash',
  cwd: '~/UO/mus616/lambda-source',
  nodeJsPath: '~.local/share/fnm/node-versions/v22.13.1/installation/bin/node',
  scriptPath: '~/.serverless/releases/4.7.0/package/dist/sf-core.js',
  scriptArgs: [ 'package', '--stage', 'stg', '--region', 'eu-west-1', '--debug' ],
  logLevel: 'debug',
  isInteractive: true
}
s:core: { serverless_framework: '4.7.0' }
s:main: Initializing
s:main: Initializing
s:core:router: {
  command: [ 'package' ],
  options: { stage: 'stg', region: 'eu-west-1', debug: '*' },
  versions: { serverless_framework: '4.7.0' },
  compose: undefined
}
s:core:router: ComposeRunner returned an empty customConfigFilePath, skipping
s:core:router: CfnRunner returned an empty customConfigFilePath, skipping
s:core:router: ServerlessContainerFrameworkRunner returned an empty customConfigFilePath, skipping
s:core:router: TraditionalRunner returned an empty customConfigFilePath, skipping
s:resolve-variables-and-authenticate: Authenticating
s:core:auth:get-authenticated-data: access key provided manually
s:main: Finalizing (and 1 more task)
s:core:router: Saving meta record to global .serverless directory.
s:core:router: Finalization failed: Error publishing telemetry event batches: Not authenticated
s:core:router:finalization-error-handler: Error during finalization: Error: Sending events failed: Error publishing telemetry event batches: Not authenticated
s:core:router:finalization-error-handler: Error during telemetry event handling: Not authenticated
s:cli-error-handler: Error: Unauthorized
    at Authentication.getClientDataFromAccessKey (~/.serverless/releases/4.7.0/sf-core/src/lib/auth/index.js:1075:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Authentication.getAuthenticatedData (~/.serverless/releases/4.7.0/sf-core/src/lib/auth/index.js:184:26)
    at async Authentication.authenticate (~/.serverless/releases/4.7.0/sf-core/src/lib/auth/index.js:1286:12)
    at async TraditionalRunner.resolveVariablesAndAuthenticate (~/.serverless/releases/4.7.0/sf-core/src/lib/runners/index.js:272:30)
    at async TraditionalRunner.run ~/.serverless/releases/4.7.0/sf-core/src/lib/runners/framework.js:78:31)
    at async route (~/.serverless/releases/4.7.0/sf-core/src/lib/router.js:102:20)
    at async Object.run (~/.serverless/releases/4.7.0/sf-core/src/index.js:39:3)
    at async run2 (~/.serverless/releases/4.7.0/sf-core/bin/sf-core.js:31:3)

✖ Error: Unauthorized
    at Authentication.getClientDataFromAccessKey (~/.serverless/releases/4.7.0/sf-core/src/lib/auth/index.js:1075:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Authentication.getAuthenticatedData (~/.serverless/releases/4.7.0/sf-core/src/lib/auth/index.js:184:26)
    at async Authentication.authenticate (~/.serverless/releases/4.7.0/sf-core/src/lib/auth/index.js:1286:12)
    at async TraditionalRunner.resolveVariablesAndAuthenticate (~/.serverless/releases/4.7.0/sf-core/src/lib/runners/index.js:272:30)
    at async TraditionalRunner.run (~/.serverless/releases/4.7.0/sf-core/src/lib/runners/framework.js:78:31)
    at async route (~/.serverless/releases/4.7.0/sf-core/src/lib/router.js:102:20)
    at async Object.run (~/.serverless/releases/4.7.0/sf-core/src/index.js:39:3)
    at async run2 (~/.serverless/releases/4.7.0/sf-core/bin/sf-core.js:31:3)

For help, try the following:
  • Run the command again with the "--debug" option
  • Run "serverless support"
  • Review the docs: https://www.serverless.com/framework/docs/
ktroy78 commented 1 month ago

I am having a similar

czubocha commented 1 month ago

Hey @CirrusHQ-Pipeline-User @ktroy78, thanks for reporting this. Did you start seeing this after upgrading to v4.7.0, or did it just start happening without any changes on your side?

ktroy78 commented 1 month ago

Greetings @czubocha I thought my initial deployment was in serverless v4, however I noticed that a peer dependency in my package-lock.json file resulted in a v3 deployment.

After correcting for this package dependency I started receiving the error message

ktroy78 commented 1 month ago

I have followed all the steps outlined in the documentation for upgrading, but cannot seem to resolve the error message

CirrusHQ-Pipeline-User commented 1 month ago

@czubocha same scenario for me

czubocha commented 1 month ago

Got it. Please check the following steps to troubleshoot the issue:

  1. If you’re using the SERVERLESS_ACCESS_KEY environment variable, ensure that the key you're using is listed under Access Keys page in your organization settings in app.serverless.com.
  2. If you’re using a .serverlessrc file for authentication, try deleting it and running the serverless login command again.
  3. If the issue persists, please reach out to our support team so we can validate your access key.
3l-d1abl0 commented 1 month ago

@czubocha same issue.

Tried both methods. Still getting this error ! I am using v4.7.0 and node v23.6.0

ktroy78 commented 1 month ago

@czubocha sorry for the delay, we just couldn't get the KEY to work, so I resolved the error by abandoning the SERVERLESS_ACCESS_KEY in favour of the SERVERLESS_LICENCE_KEY, and using that as an env var instead.

3l-d1abl0 commented 1 month ago

@ktroy78 This worked. Thanks !