mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
fix(enterprise/audit): improve error message for missing action (#8335)
This commit is contained in:
@@ -2,7 +2,9 @@ package audit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
||||
"github.com/coder/coder/coderd/database"
|
||||
"github.com/coder/coder/codersdk"
|
||||
@@ -235,7 +237,9 @@ func entry(v any, f map[string]Action) (string, map[string]Action) {
|
||||
continue
|
||||
}
|
||||
if _, ok := fcpy[jsonTag]; !ok {
|
||||
panic(fmt.Sprintf("audit table entry missing action for field %q in type %q", d.FieldType.Name, name))
|
||||
_, _ = fmt.Fprintf(os.Stderr, "ERROR: Audit table entry missing action for field %q in type %q\nPlease update the auditable resource types in: %s\n", d.FieldType.Name, name, self())
|
||||
//nolint:revive
|
||||
os.Exit(1)
|
||||
}
|
||||
delete(fcpy, jsonTag)
|
||||
}
|
||||
@@ -252,3 +256,9 @@ func entry(v any, f map[string]Action) (string, map[string]Action) {
|
||||
func (t Action) String() string {
|
||||
return string(t)
|
||||
}
|
||||
|
||||
func self() string {
|
||||
//nolint:dogsled
|
||||
_, file, _, _ := runtime.Caller(1)
|
||||
return file
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user