fix: return 204 No Content from preferred sources endpoint

The API client expects empty responses to use 204, not 200.
Returning 200 with no body caused JSON parse error in the frontend.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
master
oabrivard 2 months ago
parent a566a60663
commit f0b60f3f13

@ -324,5 +324,5 @@ pub async fn update_preferred(
}
db::sources::update_preferred(&state.pool, auth_user.id, &body.source_ids, body.theme_id).await?;
Ok(StatusCode::OK)
Ok(StatusCode::NO_CONTENT)
}

@ -62,7 +62,7 @@ async fn update_preferred_sets_sources() {
let (pref_status, _) = app
.put_with_session("/api/v1/sources/preferred", &pref_body, &session)
.await;
assert_eq!(pref_status, StatusCode::OK);
assert_eq!(pref_status, StatusCode::NO_CONTENT);
// GET /sources → verify preferred flags
let (list_status, list_body) = app
@ -132,7 +132,7 @@ async fn update_preferred_clears_all_when_empty() {
let (pref_status, _) = app
.put_with_session("/api/v1/sources/preferred", &pref_body, &session)
.await;
assert_eq!(pref_status, StatusCode::OK);
assert_eq!(pref_status, StatusCode::NO_CONTENT);
// Clear all preferred
let clear_body = serde_json::json!({

@ -638,7 +638,7 @@ async fn preferred_sources_processed_first() {
let (pref_status, _) = app
.put_with_session("/api/v1/sources/preferred", &pref_body, &session)
.await;
assert_eq!(pref_status.as_u16(), 200, "Setting preferred sources should succeed");
assert_eq!(pref_status.as_u16(), 204, "Setting preferred sources should succeed");
// Run the pipeline
let mock_provider = MockLlmProvider::new()

@ -132,7 +132,7 @@ test.describe('Sources management', () => {
});
return { status: resp.status };
}, { ids: [sourceId2], tid: themeId });
expect(prefResp.status).toBe(200);
expect(prefResp.status).toBe(204);
// Step 9: Verify source is now preferred
const listResp3 = await page.evaluate(async (tid: string) => {

Loading…
Cancel
Save