pocketbase/pocketbase · error
failed to dop index - missing index name: %s
Error message
failed to dop index - missing index name: %s
What it means
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.
Source
Thrown at core/collection_record_table_sync.go:312
}
return nil
})
}
func dropCollectionIndexes(app App, collection *Collection) error {
if collection.IsView() {
return nil // views don't have indexes
}
return app.RunInTransaction(func(txApp App) error {
for _, raw := range collection.Indexes {
parsed := dbutils.ParseIndex(raw)
// note: don't check IsValid because the index table name may not be populated
// (https://github.com/pocketbase/pocketbase/issues/7689)
if parsed.IndexName == "" {
return fmt.Errorf("failed to dop index - missing index name: %s", raw)
}
_, err := txApp.DB().NewQuery(fmt.Sprintf("DROP INDEX IF EXISTS [[%s]]", parsed.IndexName)).Execute()
if err != nil {
return err
}
}
return nil
})
}
func createCollectionIndexes(app App, collection *Collection) error {
if collection.IsView() {
return nil // views don't have indexes
}
return app.RunInTransaction(func(txApp App) error {View on GitHub (pinned to 5d217ddb50)
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.
Example fix
// before: unnamed index in the collection definition // CREATE INDEX ON posts(title) // after: explicitly named index // CREATE INDEX idx_posts_title ON posts(title)
Defensive patterns
Strategy: validation
Validate before calling
for _, raw := range collection.Indexes {
if dbutils.ParseIndex(raw).IndexName == "" {
return fmt.Errorf("collection has an unnamed index: %s", raw)
}
} Try / catch
if err := app.Delete(collection); err != nil {
if strings.Contains(err.Error(), "missing index name") {
// strip the broken index entry, then retry the delete
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to save collection %q: %w
- [%s] failed to check collection references: %w
- failed to rename column %s - %w
- failed to fetch old collection state: %w
- _collections exec error: %w
AI-assisted analysis of pocketbase/pocketbase@5d217ddb50 (2026-08-15).
Data as JSON: /api/errors/27cf7788263382fb.
Report an issue: GitHub.