{"record":{"id":"8e019e9ad5809cf7","repo":"crowdsecurity/crowdsec","slug":"loading-scenario-dump-file-s-w","errorCode":null,"errorMessage":"loading scenario dump file '%s': %w","messagePattern":"loading scenario dump file '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/scenario_assert.go","lineNumber":63,"sourceCode":"\n\treturn ScenarioAssert\n}\n\nfunc (s *ScenarioAssert) AutoGenFromFile(filename string) (string, error) {\n\terr := s.LoadTest(filename, \"\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tret := s.AutoGenScenarioAssert()\n\n\treturn ret, nil\n}\n\nfunc (s *ScenarioAssert) LoadTest(filename string, bucketpour string) error {\n\tbucketDump, err := LoadScenarioDump(filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"loading scenario dump file '%s': %w\", filename, err)\n\t}\n\n\ts.TestData = bucketDump\n\n\tif bucketpour != \"\" {\n\t\tpourDump, err := dumps.LoadBucketPourDump(bucketpour)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"loading bucket pour dump file '%s': %w\", filename, err)\n\t\t}\n\n\t\ts.PourData = pourDump\n\t}\n\n\treturn nil\n}\n\nfunc (s *ScenarioAssert) AssertFile(testFile string) error {\n\tfile, err := os.Open(s.File)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/scenario_assert.go#L45-L81","documentation":"ScenarioAssert.LoadTest loads the serialized bucket dump (the .dump file produced when running the scenario) via LoadScenarioDump. If reading or unmarshalling that dump fails, the error is wrapped naming the dump file. It indicates the test's assertion input file is missing, unreadable, or in an unexpected format.","triggerScenarios":"LoadTest (called by AutoGenFromFile or AssertFile) with a filename that doesn't exist, isn't readable, or contains an invalid/outdated dump serialization.","commonSituations":"Running assertions before generating the dump (cscli hubtest run not executed); dump file deleted by CI cleanup; dump produced by an older crowdsec version with a different serialization shape.","solutions":["Re-run the test to (re)generate the dump file: cscli hubtest run <test>.","Verify the dump file path exists and is readable.","Regenerate dumps if they were produced by an older crowdsec version.","Inspect the wrapped error to distinguish file-not-found from unmarshal failure."],"exampleFix":"// before\nassert.LoadTest(\"tests/ssh-bf/dump-but-no-dump-file\", \"\")\n// after\n// run: cscli hubtest run ssh-bf  (creates the dump), then:\nassert.LoadTest(\"tests/ssh-bf/dump\", \"\")","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(dumpFile); err != nil || fi.Size() == 0 {\n\treturn fmt.Errorf(\"dump file %s missing or empty; run the test first\", dumpFile)\n}","typeGuard":null,"tryCatchPattern":"if err := assert.LoadTest(dumpFile, pourFile); err != nil {\n\tif os.IsNotExist(errors.Unwrap(err)) {\n\t\treturn fmt.Errorf(\"run 'cscli hubtest run' to generate %s first\", dumpFile)\n\t}\n\treturn err\n}","preventionTips":["Always run the scenario (generating the dump) before assertions.","Keep dump files in CI artifacts if assertions run in a later stage.","Regenerate dumps after upgrading crowdsec."],"tags":["crowdsec","hubtest","assert","dump"],"backgroundTag":"file-read-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}