{"record":{"id":"bd4e6f18090473b6","repo":"wavetermdev/waveterm","slug":"file-s-s-is-not-an-ijson-file","errorCode":null,"errorMessage":"file %s:%s is not an ijson file","messagePattern":"file (.+?):(.+?) is not an ijson file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/filestore/blockstore.go","lineNumber":317,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\tnewBytes, err := ijson.CompactIJson(fullData, entry.File.Opts.IJsonBudget)\n\tif err != nil {\n\t\treturn err\n\t}\n\tentry.writeAt(0, newBytes, true)\n\treturn nil\n}\n\nfunc (s *FileStore) CompactIJson(ctx context.Context, zoneId string, name string) error {\n\treturn withLock(s, zoneId, name, func(entry *CacheEntry) error {\n\t\terr := entry.loadFileIntoCache(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !entry.File.Opts.IJson {\n\t\t\treturn fmt.Errorf(\"file %s:%s is not an ijson file\", zoneId, name)\n\t\t}\n\t\treturn s.compactIJson(ctx, entry)\n\t})\n}\n\nfunc (s *FileStore) AppendIJson(ctx context.Context, zoneId string, name string, command map[string]any) error {\n\tdata, err := ijson.ValidateAndMarshalCommand(command)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn withLock(s, zoneId, name, func(entry *CacheEntry) error {\n\t\terr := entry.loadFileIntoCache(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !entry.File.Opts.IJson {\n\t\t\treturn fmt.Errorf(\"file %s:%s is not an ijson file\", zoneId, name)\n\t\t}","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/filestore/blockstore.go#L299-L335","documentation":"CompactIJson requires the target file to have been created with the IJson option. IJson files are compacted via a special command-log compaction path (compactIJson); calling it on a regular binary/append file would corrupt or misread its parts, so it is rejected.","triggerScenarios":"Calling CompactIJson(ctx, zoneId, name) on a file whose File.Opts.IJson flag is false — i.e. the file was created via WriteAt/regular writes without the IJson option set at creation time.","commonSituations":"Config drift where the creating code no longer sets Opts.IJson but the compacting job assumes it; pointing a compaction routine at a zone/file name that holds a normal file; migration scripts compacting legacy files.","solutions":["Verify the file was created with the IJson option enabled; recreate it with Opts.IJson = true if it was not.","Check zoneId/name for typos so you are not compacting the wrong file.","Only run CompactIJson from code paths that own IJson file creation."],"exampleFix":"// before\nfs.CompactIJson(ctx, zone, name) // file is a plain file\n// after\nif file, _ := fs.StatFile(ctx, zone, name); file != nil && !file.Opts.IJson {\n    return fmt.Errorf(\"%s:%s is not ijson\", zone, name)\n}\nfs.CompactIJson(ctx, zone, name)","handlingStrategy":"validation","validationCode":"if fi, err := fs.StatFile(ctx, zone, name); err == nil && !fi.Opts.IJson {\n    return fmt.Errorf(\"%s:%s is not ijson; cannot compact\", zone, name)\n}","typeGuard":"func isIJson(f *fs.FileInfo) bool { return f != nil && f.Opts.IJson }","tryCatchPattern":"_, err := fs.CompactIJson(ctx, zone, name)\nif err != nil && strings.Contains(err.Error(), \"is not an ijson file\") {\n    // wrong file type: recreate as IJson or use regular compaction\n}","preventionTips":["Create all command-log files with Opts.IJson = true in one shared helper.","Keep zone/name constants together with the flags they were created with.","Gate compaction jobs on the IJson flag rather than name conventions."],"tags":["filestore","ijson","type-mismatch"],"backgroundTag":"unsupported-file-type","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}