Skip to content

Commit

Permalink
prevent runtime panic in error logging package (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist authored Jul 15, 2022
1 parent 3f0c277 commit 56aa7d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/fastly/static/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ api_endpoint = "https://api.fastly.com"
remote_config = "https://developer.fastly.com/api/internal/cli-config"
ttl = "5m"

[language.go]
tinygo_constraint = ">= 0.24.0-0"
toolchain_constraint = ">= 1.17 < 1.19"

[language.rust]
toolchain_version = "1.56.1"
toolchain_constraint = ">= 1.56.1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/compute/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ func manageExistingServiceFlow(
return serviceVersion, err
}
if serviceDetails.Type != "wasm" {
errLog.AddWithContext(err, map[string]interface{}{
errLog.AddWithContext(fmt.Errorf("error: invalid service type: '%s'", serviceDetails.Type), map[string]interface{}{
"Service ID": serviceID,
"Service Version": serviceVersion,
"Service Type": serviceDetails.Type,
Expand Down
6 changes: 5 additions & 1 deletion pkg/errors/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ func createLogEntry(err error) LogEntry {

_, file, line, ok := runtime.Caller(2)
if ok {
idx := strings.Index(file, "/pkg/")
if idx == -1 {
idx = 0
}
le.Caller = map[string]interface{}{
"FILE": file[strings.Index(file, "/pkg/"):],
"FILE": file[idx:],
"LINE": line,
}
}
Expand Down

0 comments on commit 56aa7d7

Please sign in to comment.