outline/outline · error · Error
Sort field must be one of title,index
Error message
Sort field must be one of title,index
What it means
The third leg of the Collection.sort validator: field must be one of 'title' or 'index'. Any other field name (e.g. 'createdAt', 'name') is rejected even if the shape and direction are valid.
Source
Thrown at server/models/Collection.ts:291
@Column({
type: DataType.JSONB,
validate: {
isSort(value: CollectionSort) {
if (
typeof value !== "object" ||
!value.direction ||
!value.field ||
Object.keys(value).length !== 2
) {
throw new Error("Sort must be an object with field,direction");
}
if (!["asc", "desc"].includes(value.direction)) {
throw new Error("Sort direction must be one of asc,desc");
}
if (!["title", "index"].includes(value.field)) {
throw new Error("Sort field must be one of title,index");
}
},
},
})
sort: CollectionSort;
/** Whether the collection is archived, and if so when. */
@IsDate
@Column(DataType.DATE)
archivedAt: Date | null;
/** The minimum permission level required to manage templates in this collection. */
@IsIn([[CollectionPermission.Admin, CollectionPermission.ReadWrite]])
@Default(CollectionPermission.Admin)
@Column(DataType.STRING)
templateManagement: CollectionPermission;
/** Allows the configuration of commenting per collection. */View on GitHub (pinned to 935a44d4c0)
Solutions
- Use only 'title' or 'index' as the sort field.
- If you need other sort criteria, extend the validator allow-list and ensure the DB query supports it.
- Constrain the UI sort dropdown to the supported fields.
Example fix
// before
sort: { field: 'createdAt', direction: 'asc' }
// after
sort: { field: 'title', direction: 'asc' } Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = ['title', 'index'] as const;
if (!ALLOWED.includes(sort.field)) {
throw new ValidationError(`sort.field must be one of ${ALLOWED.join(',')}`);
} Type guard
const isSortField = (f: unknown): f is 'title' | 'index' => f === 'title' || f === 'index';
Prevention
- Restrict the sort dropdown to title and index.
- Extend the validator (and the query layer) if you add new sortable fields.
- Validate at the API boundary to give a clean 400.
When it happens
Trigger: Setting sort.field to anything other than 'title' or 'index', e.g. when a client tries to sort by a custom attribute.
Common situations: Assuming arbitrary fields are sortable; carrying over a sort field from another product; UI exposing columns the backend doesn't support sorting by.
Related errors
- Sort direction must be one of asc,desc
- Sort must be an object with field,direction
- Revision does not belong to this document
- The name of this group is already in use
- Must be a fully qualified domain name
AI-assisted analysis of outline/outline@935a44d4c0 (2026-08-12).
Data as JSON: /api/errors/61de7fe60be37aee.
Report an issue: GitHub.