Bugsnag抛出了无效的API密钥错误。

huangapple go评论81阅读模式
英文:

Bugsnag is throwing invalid api key: '' error

问题

我正在使用go v1.19构建一个go应用程序。我已经在Linux操作系统中使用服务文件运行了这个应用程序。

以下是我初始化bugsnag的代码:

package main

import (
	"github.com/bugsnag/bugsnag-go"
	bugsnaggin "github.com/bugsnag/bugsnag-go-gin"
	"github.com/gin-gonic/gin"
)

func init() {
	BugsnagAutoNotify()
}
func main() {
	InitRoutes()
}

var routes = Routes{
	Route{"GET", "/test", test},
}

func InitRoutes() {
	router := gin.Default()
	for _, route := range routes {
		switch route.Method {
		case "GET":
			router.GET(route.Url, route.HandlerFunc)
		case "POST":
			router.POST(route.Url, route.HandlerFunc)
		default:
			router.GET(route.Url, func(c *gin.Context) {
				c.JSON(200, gin.H{
					"result": "Specify a valid http method with this route.",
				})
			})
		}
	}
	router.Run(":8080")
}

func BugsnagAutoNotify() gin.HandlerFunc {
	return bugsnaggin.AutoNotify(bugsnag.Configuration{
		APIKey:          bugsnagApiKey,
		ProjectPackages: []string{"main"},
		AppVersion:      bugsnagAppVersion,
	})
}

但是当我在测试处理程序中调用bugsnag.Notify(err, metadata)时,它显示以下内容:

bugsnag/defaultReportPublisher.publishReport: bugsnag/payload.deliver: invalid api key: ''

这里有什么问题?

英文:

I am using go v1.19 to build a go application. I have run this application using a service file in linux OS.

Below in my code to initialize the bugsnag:


package main

import (
	"github.com/bugsnag/bugsnag-go"
	bugsnaggin "github.com/bugsnag/bugsnag-go-gin"
	"github.com/gin-gonic/gin"
)

func init() {
	BugsnagAutoNotify()
}
func main() {
	InitRoutes()
}

var routes = Routes{
	Route{"GET", "/test", test},
}

func InitRoutes() {
	router := gin.Default()
	for _, route := range routes {
		switch route.Method {
		case "GET":
			router.GET(route.Url, route.HandlerFunc)
		case "POST":
			router.POST(route.Url, route.HandlerFunc)
		default:
			router.GET(route.Url, func(c *gin.Context) {
				c.JSON(200, gin.H{
					"result": "Specify a valid http method with this route.",
				})
			})
		}
	}
	router.Run(":8080")
}

func BugsnagAutoNotify() gin.HandlerFunc {
	return bugsnaggin.AutoNotify(bugsnag.Configuration{
		APIKey:          bugsnagApiKey,
		ProjectPackages: []string{"main"},
		AppVersion:      bugsnagAppVersion,
	})
}

But when I call bugsnag.Notify(err, metadata) in test handler it says following:

bugsnag/defaultReportPublisher.publishReport: bugsnag/payload.deliver: invalid api key: ''

whats wrong here ?

答案1

得分: 1

我刚刚将导入语句更改为"github.com/bugsnag/bugsnag-go/v2",对我来说有效。

英文:

I just changed the import statement to "github.com/bugsnag/bugsnag-go/v2" and it worked for me.

答案2

得分: 0

如果您仍然对此有问题,请随时发送邮件至support@bugsnag.com。

英文:

If you're still having problems with this please feel free to write in to support@bugsnag.com.

huangapple
  • 本文由 发表于 2023年4月25日 14:14:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76098093.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定