{"record":{"id":"27cf7788263382fb","repo":"pocketbase/pocketbase","slug":"failed-to-dop-index-missing-index-name-s","errorCode":null,"errorMessage":"failed to dop index - missing index name: %s","messagePattern":"failed to dop index - missing index name: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/collection_record_table_sync.go","lineNumber":312,"sourceCode":"\t\t}\n\n\t\treturn nil\n\t})\n}\n\nfunc dropCollectionIndexes(app App, collection *Collection) error {\n\tif collection.IsView() {\n\t\treturn nil // views don't have indexes\n\t}\n\n\treturn app.RunInTransaction(func(txApp App) error {\n\t\tfor _, raw := range collection.Indexes {\n\t\t\tparsed := dbutils.ParseIndex(raw)\n\n\t\t\t// note: don't check IsValid because the index table name may not be populated\n\t\t\t// (https://github.com/pocketbase/pocketbase/issues/7689)\n\t\t\tif parsed.IndexName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"failed to dop index - missing index name: %s\", raw)\n\t\t\t}\n\n\t\t\t_, err := txApp.DB().NewQuery(fmt.Sprintf(\"DROP INDEX IF EXISTS [[%s]]\", parsed.IndexName)).Execute()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n}\n\nfunc createCollectionIndexes(app App, collection *Collection) error {\n\tif collection.IsView() {\n\t\treturn nil // views don't have indexes\n\t}\n\n\treturn app.RunInTransaction(func(txApp App) error {","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/pocketbase/pocketbase/blob/5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457/core/collection_record_table_sync.go#L294-L330","documentation":"Thrown by dropCollectionIndexes when a collection's index definition cannot be parsed into a named index. The code deliberately does not check full index validity (the table name may be unpopulated per pocketbase issue #7689), but it requires a non-empty index name so it can build the DROP INDEX IF EXISTS statement. 'dop' is a typo for 'drop' in the message itself.","triggerScenarios":"Deleting a collection (or otherwise triggering dropCollectionIndexes) where collection.Indexes contains an entry that dbutils.ParseIndex(raw) parses to an empty IndexName — e.g. a manually crafted index string without an INDEX name clause, or a corrupted _collections row edited by hand or by an external tool.","commonSituations":"Hand-edited index definitions in the Admin UI raw JSON editor; importing a collection JSON whose indexes array contains a malformed CREATE INDEX statement; downgrading from a newer PocketBase that emitted an index format the current version's parser doesn't understand.","solutions":["Inspect the collection's indexes array (collection.Indexes or the _collections table) and find the entry that lacks an index name.","Fix or remove the malformed index string, giving it an explicit name (CREATE INDEX idx_xxx ON ...) via the Admin UI or API.","If the collection is being deleted anyway, clear the broken index entry first, then delete the collection.","Never hand-edit index SQL without including a named INDEX clause."],"exampleFix":"// before: unnamed index in the collection definition\n// CREATE INDEX ON posts(title)\n\n// after: explicitly named index\n// CREATE INDEX idx_posts_title ON posts(title)","handlingStrategy":"validation","validationCode":"for _, raw := range collection.Indexes {\n    if dbutils.ParseIndex(raw).IndexName == \"\" {\n        return fmt.Errorf(\"collection has an unnamed index: %s\", raw)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := app.Delete(collection); err != nil {\n    if strings.Contains(err.Error(), \"missing index name\") {\n        // strip the broken index entry, then retry the delete\n    }\n}","preventionTips":["Always name indexes explicitly (CREATE INDEX idx_x ON ...).","Validate collection JSON imports before applying them.","Don't hand-edit index SQL strings in the Admin UI raw editor."],"tags":["database","indexes","collections","data-corruption"],"backgroundTag":null,"analyzedSha":"5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457","analyzedAt":"2026-08-15T10:06:33.165Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}