nocobase/nocobase · error
The record does not exist
Error message
The record does not exist
What it means
SingleRelationRepository.update first fetches the related target record by the given filter/targetCollection. If no matching record exists, it throws 'The record does not exist' rather than silently returning. The association target row identified by your filter/query could not be loaded before applying values.
Source
Thrown at packages/core/database/src/relation-repository/single-relation-repository.ts:99
transaction,
});
return true;
}
@transaction()
@injectTargetCollection
async update(options: UpdateOptions): Promise<any> {
const transaction = await this.getTransaction(options);
const target = await this.find({
transaction,
// @ts-ignore
targetCollection: options.targetCollection,
});
if (!target) {
throw new Error('The record does not exist');
}
await updateModelByValues(target, options?.values, {
...options,
transaction,
});
if (options.hooks !== false) {
await this.db.emitAsync(`${this.targetCollection.name}.afterUpdateWithAssociations`, target, {
...options,
transaction,
});
const eventName = `${this.targetCollection.name}.afterSaveWithAssociations`;
await this.db.emitAsync(eventName, target, { ...options, transaction });
}
return target;
}View on GitHub (pinned to fa42722fef)
Solutions
- Verify the record exists with a findOne/filter call using the same tk/filter before updating
- Correct the filterByTk / filter value or targetCollection option
- Handle the deleted-record case gracefully in the caller (create instead, or surface a 404)
Example fix
// before
await repo.update({ filterByTk: id, values }); // throws if deleted
// after
const exists = await repo.findOne({ filterByTk: id });
if (!exists) throw new NotFoundError(`Record ${id} not found`);
await repo.update({ filterByTk: id, values }); Defensive patterns
Strategy: try-catch
Validate before calling
const exists = await singleRepo.findOne({ filterByTk: id });
if (!exists) throw new NotFoundError(`Related record ${id} not found`); Type guard
const hasTarget = async (repo, opts) => (await repo.findOne(opts)) !== null;
Try / catch
try { await singleRepo.update({ filterByTk: id, values }); } catch (e) { if (e.message === 'The record does not exist') { throw new NotFoundError(id); } throw e; } Prevention
- Check record existence before relation updates
- Refresh stale IDs from the client after deletes
- Pass correct targetCollection option
When it happens
Trigger: Calling singleRelationRepository.update({ filterByTk: id, values }) (or via relation field update) where the related record with that tk was deleted, never existed, or the filter matches nothing; wrong targetCollection option passed.
Common situations: Stale UI referencing a deleted record; race condition where the record was removed between listing and updating; using the wrong primary key value or wrong collection name; multi-tenant/filter scoping hiding the record.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Repository can not handle action ${repositoryMethod} for ${c
- must provide filter or filterByTk for ${propertyKey} call, o
- Association "${include.association}" not found in model "${e
- Field must be of type Array
- filterByTk invalid
AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01).
Data as JSON: /api/errors/e88850bcfb1b50fc.
Report an issue: GitHub.