{"record":{"id":"509fca885c8ae067","repo":"owasp-amass/amass","slug":"failed-to-cast-the-msg-value","errorCode":null,"errorMessage":"failed to cast the msg value","messagePattern":"failed to cast the msg value","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/slog.go","lineNumber":49,"sourceCode":"\tdelete(j, slog.TimeKey)\n\n\tvar level slog.Level\n\t// extract the log level for the new record\n\tif val, found := j[slog.LevelKey]; !found {\n\t\treturn slog.Record{}, errors.New(\"failed to find the level key\")\n\t} else if str, ok := val.(string); !ok {\n\t\treturn slog.Record{}, errors.New(\"failed to cast the level value\")\n\t} else if level.UnmarshalText([]byte(str)) != nil {\n\t\treturn slog.Record{}, errors.New(\"failed to unmarshal the level text\")\n\t}\n\tdelete(j, slog.LevelKey)\n\n\tvar msg string\n\t// extract the log message for the new record\n\tif val, found := j[slog.MessageKey]; !found {\n\t\treturn slog.Record{}, errors.New(\"failed to find the msg key\")\n\t} else if str, ok := val.(string); !ok {\n\t\treturn slog.Record{}, errors.New(\"failed to cast the msg value\")\n\t} else {\n\t\tmsg = str\n\t}\n\tdelete(j, slog.MessageKey)\n\n\tvar pc uintptr\n\trecord := slog.NewRecord(ltime, level, msg, pc)\n\trecord.AddAttrs(jsonToAttrs(j)...)\n\treturn record, nil\n}\n\nfunc jsonToAttrs(jmap map[string]any) []slog.Attr {\n\tvar attrs []slog.Attr\n\n\tfor k, v := range jmap {\n\t\tswitch val := v.(type) {\n\t\tcase bool:\n\t\t\tattrs = append(attrs, slog.Bool(k, val))","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/slog.go#L31-L67","documentation":"JSONLogToRecord found the msg (slog.MessageKey) entry in the JSON log record but its value is not a string (e.g. a number, object, or null), so the type assertion val.(string) fails. This is a type-shape mismatch in the input JSON, not a missing key; the zero slog.Record is returned with this error.","triggerScenarios":"Thrown at internal/afmt/slog.go:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the 'msg' field of the failing JSON record and coerce non-string values to strings before conversion","Fix the producer so it always writes the log message as a JSON string","If ingesting third-party JSON, normalize records (json.RawMessage decode then string conversion) before calling JSONLogToRecord"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}