File tree Expand file tree Collapse file tree
app/api/table/[tableId]/views/[viewId] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ export const PATCH = withRouteHandler(
5151 isDefault,
5252 columns,
5353 } )
54+ if ( ! view ) {
55+ return NextResponse . json ( { error : 'View not found' } , { status : 404 } )
56+ }
5457
5558 return NextResponse . json ( { success : true , data : { view } } )
5659 } catch ( error ) {
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ export interface UpdateTableViewData {
161161 * overlapping partial writes — a column resize landing while a pin is in flight —
162162 * can't each replace the whole blob from their own stale snapshot.
163163 */
164- export async function updateTableView ( data : UpdateTableViewData ) : Promise < TableView > {
164+ export async function updateTableView ( data : UpdateTableViewData ) : Promise < TableView | null > {
165165 const patch : Partial < typeof tableViews . $inferInsert > = { updatedAt : new Date ( ) }
166166 if ( data . name !== undefined ) patch . name = normalizeName ( data . name )
167167 if ( data . config !== undefined ) patch . config = data . config
@@ -193,7 +193,9 @@ export async function updateTableView(data: UpdateTableViewData): Promise<TableV
193193 return updated
194194 } )
195195
196- if ( ! row ) throw new TableViewValidationError ( 'View not found' )
196+ // `null`, not a validation error: an absent view is a missing resource, and the
197+ // route maps it to 404 the same way `deleteTableView`'s `false` does.
198+ if ( ! row ) return null
197199
198200 return toTableView ( row , data . columns )
199201}
You can’t perform that action at this time.
0 commit comments