{"record":{"id":"3bd3d8346fc9504d","repo":"SubtitleEdit/subtitleedit","slug":"element-events-not-found","errorCode":null,"errorMessage":"Element 'events' not found.","messagePattern":"Element 'events' not found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/libse/SubtitleFormats/ClqttJson.cs","lineNumber":178,"sourceCode":"                            p.Region = region;\n\n                            if (annotations.Count > 0)\n                            {\n                                p.Bookmark = String.Join(Environment.NewLine + Environment.NewLine, annotations);\n                            }\n\n                            subtitle.Paragraphs.Add(p);\n                        }\n                    }\n                    catch (Exception ex)\n                    {\n                        throw new InvalidOperationException($\"Parse error in event #{i + 1}: {ex.Message}\", ex);\n                    }\n                }\n            }\n            else\n            {\n                throw new InvalidOperationException($\"Element 'events' not found.\");\n            }\n\n            subtitle.Renumber();\n        }\n    }\n}\n","sourceCodeStart":160,"sourceCodeEnd":185,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/SubtitleFormats/ClqttJson.cs#L160-L185","documentation":"Thrown by ClqttJson.LoadSubtitle when the root JSON does not contain an 'events' element (case-insensitive find via GetRootElements). Without events there is nothing to import, so the loader aborts. Note the early-return guard only checks for the literal string \"events\"; this throw is the stricter structural check after parsing.","triggerScenarios":"A .clqtt file whose JSON root has meta but no events array, an empty events object, or a file whose events key is nested at the wrong level. Also a non-CLQTT JSON file that happens to contain the substring \"events\" and passes the initial guard.","commonSituations":"Truncated or stub CLQTT files; metadata-only exports; files misidentified as CLQTT by the auto-detector.","solutions":["Confirm the file is genuinely a CLQTT subtitle file and not another JSON format.","Ensure the root object has an \"events\": [ ... ] array with at least one entry.","Re-export from the source tool with content included."],"exampleFix":"// before\n{ \"meta\": { \"timeFormat\": \"FRAMES\" } }\n// after\n{ \"meta\": { \"timeFormat\": \"FRAMES\" }, \"events\": [ { \"eventType\": \"TIMED_TEXT_EVENT\", \"start\": 0, \"end\": 100, \"txt\": \"Hi\" } ] }","handlingStrategy":"validation","validationCode":"// Confirm an events array exists at the root before importing\nvar rootElements = parser.GetRootElements(text);\nvar eventsElement = rootElements.FirstOrDefault(e => e.Name.Equals(\"events\", StringComparison.OrdinalIgnoreCase));\nif (eventsElement == null)\n{\n    Console.WriteLine(\"No events array; nothing to import.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    new ClqttJson().LoadSubtitle(sub, lines, fileName);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Element 'events' not found\"))\n{\n    logger.Warning(\"CLQTT file has no events; skipping.\");\n}","preventionTips":["Verify the file is genuinely CLQTT before import.","Check the root JSON has an events array in a JSON viewer.","Reject metadata-only exports early."],"tags":["subtitle-format","clqtt","json","missing-element","parsing"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}