{"record":{"id":"14aa32aea65b7593","repo":"owasp-amass/amass","slug":"failed-to-find-the-msg-key","errorCode":null,"errorMessage":"failed to find the msg key","messagePattern":"failed to find the msg key","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/slog.go","lineNumber":47,"sourceCode":"\t\t}\n\t}\n\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) {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/slog.go#L29-L65","documentation":"JSONLogToRecord could not find the msg (slog.MessageKey) entry in a JSON log record it was converting back into a slog.Record. The input JSON map simply lacks the 'msg' field, so the record cannot be rebuilt; the zero slog.Record is returned along with this error. Called from WriteLogMessage when replaying/parsing JSON log output.","triggerScenarios":"Thrown at internal/afmt/slog.go:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the JSON being fed to WriteLogMessage/JSONLogToRecord and confirm each object contains a non-empty \"msg\" key","If the producer is a slog JSONHandler, verify records were serialized with the default keys (time, level, msg) and not renamed via HandlerOptions","Log or dump the offending JSON object to identify which producer emitted records without 'msg'","Skip or quarantine malformed lines instead of failing the whole conversion loop if best-effort ingestion is acceptable"],"exampleFix":null,"handlingStrategy":"validation","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"}