Skip to content

Commit 814534d

Browse files
authored
fix(enterprise/audit): improve error message for missing action (#8335)
1 parent 7fcf319 commit 814534d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

enterprise/audit/table.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package audit
22

33
import (
44
"fmt"
5+
"os"
56
"reflect"
7+
"runtime"
68

79
"github.com/coder/coder/coderd/database"
810
"github.com/coder/coder/codersdk"
@@ -235,7 +237,9 @@ func entry(v any, f map[string]Action) (string, map[string]Action) {
235237
continue
236238
}
237239
if _, ok := fcpy[jsonTag]; !ok {
238-
panic(fmt.Sprintf("audit table entry missing action for field %q in type %q", d.FieldType.Name, name))
240+
_, _ = 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())
241+
//nolint:revive
242+
os.Exit(1)
239243
}
240244
delete(fcpy, jsonTag)
241245
}
@@ -252,3 +256,9 @@ func entry(v any, f map[string]Action) (string, map[string]Action) {
252256
func (t Action) String() string {
253257
return string(t)
254258
}
259+
260+
func self() string {
261+
//nolint:dogsled
262+
_, file, _, _ := runtime.Caller(1)
263+
return file
264+
}

0 commit comments

Comments
 (0)