fix(schema-drafts): /drafts/active returns 200+null instead of 404 (no console spam)
This commit is contained in:
+15
-6
@@ -169,15 +169,24 @@ public class SchemaDraftController {
|
|||||||
/**
|
/**
|
||||||
* Convenience endpoint: фронт хочет ОДИН query'ом узнать "есть ли active
|
* Convenience endpoint: фронт хочет ОДИН query'ом узнать "есть ли active
|
||||||
* draft на этом dict'е и в каком он state'е". Returns 200 с draft body
|
* draft на этом dict'е и в каком он state'е". Returns 200 с draft body
|
||||||
* либо 404 если нет active.
|
* либо 200 с {@code null} если активного draft нет.
|
||||||
|
*
|
||||||
|
* <p><b>Why 200 + null instead of 404:</b> "no active draft" — это normal
|
||||||
|
* state, не error condition. Раньше возвращали 404 {@code no_active_draft},
|
||||||
|
* frontend silently mapped to null, но browser console всё равно logs 4xx
|
||||||
|
* network failures на каждый poll (refetchInterval=20s + invalidate after
|
||||||
|
* mutations). Spam'ило console. 200 + null body = clean console + same
|
||||||
|
* frontend behavior.
|
||||||
|
*
|
||||||
|
* <p>Frontend (queries.ts dictActiveSchemaDraftQuery) сохраняет 404→null
|
||||||
|
* fallback для backward compat и robustness — если кто-то откатит этот
|
||||||
|
* change или старый client с новым backend ещё не deployed.
|
||||||
*/
|
*/
|
||||||
@GetMapping("/api/v1/dictionaries/{name}/drafts/active")
|
@GetMapping("/api/v1/dictionaries/{name}/drafts/active")
|
||||||
public SchemaDraftResponse active(@PathVariable String name) {
|
public SchemaDraftResponse active(@PathVariable String name) {
|
||||||
DictionarySchemaDraft draft = draftService.findActive(name).orElseThrow(() ->
|
return draftService.findActive(name)
|
||||||
cloud.nstart.terravault.ordinis.restapi.error.OrdinisException.notFound(
|
.map(d -> SchemaDraftResponse.from(d, name))
|
||||||
"no_active_draft",
|
.orElse(null);
|
||||||
"У справочника " + name + " нет активного draft'а."));
|
|
||||||
return SchemaDraftResponse.from(draft, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Single draft по id (drilling в reviewer queue). */
|
/** Single draft по id (drilling в reviewer queue). */
|
||||||
|
|||||||
Reference in New Issue
Block a user