arabold/serverless-sentry-plugin

Serverless deployment fails with "fatal: No names found, cannot describe anything."

Closed this issue ยท 23 comments

Since the latest minor version change (from 2.3.0 to 2.4.0) the serverless deployment process on the project I am working on is failing with the following error message:

Error: Sentry: No Git available - Error: Command failed: git describe --exact-match --tags HEAD
fatal: No names found, cannot describe anything.

It appears that the cause is running git describe on a git repository that has no tags; the repo I'm working on has no tags.

And I can see from 612f76d#diff-1bcdce6971f2549017c3a649865c9921b7e765fb368eb43e78fbc373a779ba31 that this package is no longer suppressing errors.

Can you suggest how to proceed?

I realise that it's possible to use @sentry/serverless, but it doesn't provide the extra information that this package does in the event.extra.Event object โ€“ specifically, the args object.

I found a solution, which was to explicitly set the value of release in serverless.yml.

custom:
  sentry:
    dsn: 'redacted'
-    release: git
+    release: ${env:SENTRY_RELEASE}

The SENTRY_RELEASE env var was defined in the CI setup (GH actions, in this case).

The same issue happens on my deployment (local dev machine to AWS). My current git branch does not have a tag yet. After I add one with git tag 'TEST' it's working fine. I would like not to have to do that beforehand (though its a one time fix).

I don't believe this is a problem with 2.5.0 anymore. It's not explicit in the changelog but this case should be properly handled now. Please let me know if not.

Thanks for the update @arabold ๐Ÿ˜ƒ

When we updated to 2.5.0, we saw this error in the Sentry logs:

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '@sentry/integrations'\nRequire stack:\n- /var/task/node_modules/serverless-sentry-lib/dist/index.js\n- /var/task/src/aws/index.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module '@sentry/integrations'",
        "Require stack:",
        "- /var/task/node_modules/serverless-sentry-lib/dist/index.js",
        "- /var/task/src/aws/index.js",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
        "    at Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
        "    at file:///var/runtime/index.mjs:781:15",
        "    at file:///var/runtime/index.mjs:4:1"
    ]
}

So for the moment we have had to pin serverless-sentry-lib to v2.4.0.

We tried adding @sentry/integrations as a dependency, but still got the same message.

I looked into the changes between 2.4.0 and 2.5.0. In the package-lock.json, I found the following diff after updating to 2.5.0:

     "node_modules/serverless-sentry-lib": {
-      "version": "2.4.0",
-      "resolved": "https://registry.npmjs.org/serverless-sentry-lib/-/serverless-sentry-lib-2.4.0.tgz",
-      "integrity": "sha512-G8nK5kJ5a1ZBcWgBTaqFf9YQnk6PralHdFnDGAuWAgg3WfcJF4CvpV9VT51NYf5sKD7LWtkQC9hi7/leowTC3A==",
-      "dependencies": {
-        "@sentry/integrations": "^6.4.1"
+      "version": "2.5.0",
+      "resolved": "https://registry.npmjs.org/serverless-sentry-lib/-/serverless-sentry-lib-2.5.0.tgz",
+      "integrity": "sha512-MWs2O+EUps6/hMEblXiNnJD4X8w7uOKYa3/WTw0D8OiQdI+OBvVaNzPJlPlx35MpCiTgZbQoKvAGQAxGkRd1Sg==",
+      "engines": {
+        "node": ">=12.0.0"
       },

So version 2.4.0 added @sentry/integrations as a dependency, but 2.5.0 does not. Haven't managed to find out where/why this occurs โ€“ there's nothing obvious (to me, at least ๐Ÿ˜ ) in the 2.4.0-2.5.0 diff.

Sorry about that. You should be able to install @sentry/integrations as a new dependency to your own project. It's a peer dependency of serverless-sentry-lib now to allow the use with @sentry/node v7. I need to see if I can get rid of it completely :(

Thanks @arabold.

We tried adding @sentry/integrations as a dependency, but still got the same message.

We also tried upgrading all the @sentry packages from v6 to v7, but got a different error this time:

{
    "errorType": "TypeError",
    "errorMessage": "Cannot read properties of undefined (reading 'Info')",
    "stack": [
        "TypeError: Cannot read properties of undefined (reading 'Info')",
        "    at Runtime.handler (/var/task/node_modules/serverless-sentry-lib/dist/index.js:416:43)",
        "    at Runtime.handleOnce (file:///var/runtime/index.mjs:548:29)"
    ]
}

At least I'm pretty sure that was the result... we have spent quite a while today trying to sort out the issue.

So, that exact issue should have been fixed in serverless-sentry-lib v2.5.0 as well. That was the whole point of the exercise :( Unfortunately, I cannot test this myself right now. The error seems to indicate that it's an older version of the lib though, not 2.5.0. Mind double checking this for me?

@arabold yep, just trying to repro now ๐Ÿ˜„

will post back here as soon as I'm done

Ok, I'm back, and unfortunately we're still getting an error:

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '@sentry/integrations'\nRequire stack:\n- /var/task/node_modules/serverless-sentry-lib/dist/index.js\n- /var/task/src/aws/index.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module '@sentry/integrations'",
        "Require stack:",
        "- /var/task/node_modules/serverless-sentry-lib/dist/index.js",
        "- /var/task/src/aws/index.js",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
        "    at Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
        "    at file:///var/runtime/index.mjs:781:15",
        "    at file:///var/runtime/index.mjs:4:1"
    ]
}

Here's what is in the package.json, amongst other stuff of course:

  "dependencies": {
    "@sentry/integrations": "^7.2.0",
    "@sentry/node": "^7.2.0",
    "@sentry/serverless": "^7.2.0",
    "@sentry/types": "^7.2.0",
    "aws-lambda": "^1.0.7",
    "aws-xray-sdk": "^3.3.6",
    "serverless-sentry-lib": "^2.5.0",
    "source-map-support": "^0.5.21"
  },
  "devDependencies": {
    "@aws-sdk/types": "^3.110.0",
    "@babel/preset-env": "^7.18.2",
    "@babel/preset-typescript": "^7.17.12",
    "@types/aws-lambda": "^8.10.101",
    "aws-sdk": "^2.1158.0",
    "serverless": "^2.72.3",
    "serverless-appsync-plugin": "^1.13.0",
    "serverless-iam-roles-per-function": "^2.0.2",
    "serverless-offline": "^6.9.0",
    "serverless-plugin-log-subscription": "^1.4.0",
    "serverless-plugin-tracing": "^2.0.0",
    "serverless-prune-plugin": "^1.6.1",
    "serverless-pseudo-parameters": "^2.6.1",
    "serverless-sentry": "^2.5.0",
    "serverless-stage-manager": "^1.0.5",
    "serverless-webpack": "^5.7.1",
    "ts-loader": "^8.4.0",
    "ts-node": "^10.8.1",
    "typescript": "^4.7.4",
    "webpack": "^4.46.0",
    "webpack-node-externals": "^2.5.2"
  }

Have included a couple of other AWS-related packages, just in case they are significant.

Not missing anything obvious are we?

Maybe these two need to be aligned?

"serverless-webpack": "^5.7.1",
"webpack": "^4.46.0",

or maybe some of those devDependencies should be dependencies?

There's a new serverless-sentry-lib v2.5.1 that I just published 5 minutes ago. @sentry/integrations should be a peer dependency now and needs to be installed in your project. Only that way I could handle compatibility with v7 for now.

So, one last ask (sorry): Please update serverless-sentry-lib to v2.5.1 and then run npm install @sentry/integrations to install the new peer dependency, just to be sure. Then the errors should be gone. Sorry for the trouble.

The webpack versions should be unrelated.

Seems 2.5.1 also has a bug. Damn it. I need a test project. I'm literally on a plane over the Atlantic right now ๐Ÿ™„

@arabold thanks for the update! I thought the same re. webpack, but clutching at straws atm ๐Ÿ˜†

I saw that 2.5.1 was the latest in the code repo, but evidently it hadn't been released when I looked.

I'll give 2.5.1 a go, and get back to you. I've already got @sentry/integrations@^7.2.0 currently installed ๐Ÿ‘

Seems 2.5.1 also has a bug. Damn it. I need a test project. I'm literally on a plane over the Atlantic right now ๐Ÿ™„

Hah! That's dedication ๐Ÿ’ฏ .

Appreciate the attention you're giving this issue!

Is this the error you are referring to?

$ npm install --save serverless-sentry-lib@2.5.1
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "^>=5" of package "@sentry/integrations@^>=5": Tags may not have any characters that encodeURIComponent encodes.

v2.5.2 fixes the peer dependency now

I'm getting nuts here.

Awesome! v2.5.2, not the going nuts bit ๐Ÿ˜†

Will try now.

FIXED!!

Thank you so much for the trans-Atlantic debugging & fixing ๐ŸŽ‰

Finally! Yay! ๐ŸŽ‰ Thank you for testing and verifying. I'm gonna close this issue then and go take a nap ๐Ÿ˜ด

Well deserved ๐Ÿ’ค

Thanks for your dedication!