agnes-the-ai-analyst/app/web/templates
Vojtech c552bf8243
feat(api): enforce API design rules via pytest + fix DELETE/status-code violations (#338)
* feat(api): enforce API design rules via pytest + fix DELETE/status-code violations

Adds tests/test_api_design_rules.py with four forward-only design guardrails
that prevent new endpoints from accumulating REST debt:

  Rule 1 — No new verbs in URL paths (existing 28 grandfathered via allowlist)
  Rule 2 — DELETE must declare 204 No Content (zero allowlist entries)
  Rule 3 — Creator POSTs (path has GET counterpart) must declare 201/202
  Rule 4 — All protected /api/* routes must declare 401 and 403

Fixes found by running the rules:

- DELETE /api/admin/metrics/{metric_id}: return 204, drop redundant body
- DELETE /api/memory/{item_id}/dismiss (undismiss): return 204, drop body
- POST /api/memory/admin/contradictions: add status_code=201 (creates a resource)
- app/main.py: _add_auth_error_responses() injected into app.openapi() at startup;
  declares 401/403 on all protected /api/* operations centrally, fixing the 120
  routes that previously omitted these response codes from the spec.

Closes #337

* fix(api): resolve CI failures — extend 204 fixes + complete allowlists

- Fix remaining 6 DELETE endpoints to return 204: store entities,
  store entity install, marketplace curated install, marketplace plugin
  system flag, admin store submission, and observability view
- Update all affected tests to expect 204 (removed body assertions)
- Add 4 missing verb paths to _VERB_PATH_ALLOWLIST in test_api_design_rules.py
- Add 2 upsert endpoints to _CREATOR_POST_ALLOWLIST
- Update admin_marketplaces.html to not call r.json() on 204 DELETE

* fix(tests): align 2 DELETE-asserting tests with 204 contract (post-#339 rebase)

CI's test-shard (1) and (4) failures on this PR were caused by
Vojta's second commit (`fix(api): resolve CI failures — extend 204
fixes`) flipping more DELETE endpoints to status_code=204 than just
the two mentioned in the PR body. Two tests assert status_code==200
on the DELETE response and broke:

- tests/test_admin_store_submissions.py::TestQuarantineGates::test_admin_can_delete_quarantined
  (DELETE /api/store/entities/{entity_id})
- tests/test_store_api.py::TestInstallCycle::test_admin_hard_delete_cascades_installs
  (DELETE /api/store/entities/{entity_id}?hard=true)

Updated both to assert 204 with a comment pointing at
tests/test_api_design_rules.py rule 2 so future reviewers can
trace the contract. Verified via broader scan that no other test
asserts == 200 on a .delete() response directly (4 other sites do
.delete() then check 200 on a subsequent GET — those are fine).

* release: 0.54.26 — API design rules (test_api_design_rules.py) + 8 DELETE endpoints flip to 204

---------

Co-authored-by: ZdenekSrotyr <zdenek.srotyr@keboola.com>
2026-05-18 15:25:07 +02:00
..
admin UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
_app_header.html release(0.54.18): Curated Memory restructure + per-user Dismiss + bundled adversarial-review fixes (#316/#320/#322) (#324) 2026-05-15 18:51:05 +02:00
_claude_setup_cta.jinja fix(cta): clipboard fallback + fold Atlassian MCP into connectors (#249) 2026-05-11 21:54:51 +02:00
_claude_setup_instructions.jinja feat(web): rename /install → /setup; nav label 'Setup local agent' 2026-05-03 16:12:13 +02:00
_content_findings.html feat(store-guardrails): per-component description quality + plain-language UX (#276) 2026-05-12 21:48:27 +02:00
_content_howto_fix.html feat(store-guardrails): per-component description quality + plain-language UX (#276) 2026-05-12 21:48:27 +02:00
_flea_versions.html fix(store): surface review failures + harden publish gate (#316) 2026-05-15 15:52:07 +02:00
_home_stats.html feat(home): status frame on /home (operator-gated, onboarded-only) (#297) 2026-05-14 09:28:47 +00:00
_marketplace_video_embed.html Curated marketplace enrichment via agnes-metadata.json + curator metadata (#234) 2026-05-09 17:01:37 +02:00
_message.html feat(auth): password reset & invite flows for web + admin (#34) (#37) 2026-04-22 17:43:57 +02:00
_page_chrome.html feat(home): state-aware /home + /setup-advanced + schema v26 (#228) 2026-05-08 18:28:47 +02:00
_page_hero.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
_posthog.html feat(observability): optional PostHog integration (#231) 2026-05-08 17:57:10 +04:00
_profile_tokens.html feat(web): consolidate the personal /me/* surface — /me/activity + /me/profile (#304) 2026-05-14 21:29:51 +02:00
_profile_troubleshooting.html feat(web): consolidate the personal /me/* surface — /me/activity + /me/profile (#304) 2026-05-14 21:29:51 +02:00
_quarantine_banner.html fix(store): surface review failures + harden publish gate (#316) 2026-05-15 15:52:07 +02:00
_theme.html feat: complete system — web UI, all API endpoints, governance, admin, CLI commands 2026-03-27 16:52:22 +01:00
_version_badge.html feat(ui): version badge as shared partial, injected into every full-page template 2026-04-21 20:51:55 +02:00
activity_center.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_access.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_corporate_memory.html feat(memory): bulk-edit batch bar on All Items tab (#129) (#325) 2026-05-15 20:05:21 +02:00
admin_group_detail.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_groups.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_marketplaces.html feat(api): enforce API design rules via pytest + fix DELETE/status-code violations (#338) 2026-05-18 15:25:07 +02:00
admin_scheduler_runs.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_server_config.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_session_detail.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_sessions.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_store_submission_detail.html fix(store): restore reuses prior approved verdict + admin detail surfaces content_quality (#332) 2026-05-16 07:12:29 +02:00
admin_store_submissions.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_tables.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_tokens.html feat(web): consolidate the personal /me/* surface — /me/activity + /me/profile (#304) 2026-05-14 21:29:51 +02:00
admin_usage.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_user_detail.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_users.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_welcome.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
admin_workspace_prompt.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
base.html release(0.54.18): Curated Memory restructure + per-user Dismiss + bundled adversarial-review fixes (#316/#320/#322) (#324) 2026-05-15 18:51:05 +02:00
base_login.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
catalog.html feat(catalog): promote buckets to top-level Data Package cards (#301) 2026-05-14 15:18:35 +02:00
corporate_memory.html release(0.54.18): Curated Memory restructure + per-user Dismiss + bundled adversarial-review fixes (#316/#320/#322) (#324) 2026-05-15 18:51:05 +02:00
dashboard.html UI design system unification — one stylesheet, canonical primitives, nav fix (#284) 2026-05-14 13:28:03 +02:00
desktop_link.html feat: complete system — web UI, all API endpoints, governance, admin, CLI commands 2026-03-27 16:52:22 +01:00
error.html feat(observability): request_id end-to-end + dev debug toolbar + centralized logging (#136) 2026-04-29 22:54:21 +02:00
home_not_onboarded.html release(0.54.18): Curated Memory restructure + per-user Dismiss + bundled adversarial-review fixes (#316/#320/#322) (#324) 2026-05-15 18:51:05 +02:00
home_onboarded.html release(0.54.18): Curated Memory restructure + per-user Dismiss + bundled adversarial-review fixes (#316/#320/#322) (#324) 2026-05-15 18:51:05 +02:00
install.html feat(web): consolidate the personal /me/* surface — /me/activity + /me/profile (#304) 2026-05-14 21:29:51 +02:00
login.html feat(setup): configurable instance brand + connector setup overhaul (#268) 2026-05-12 17:10:08 +02:00
login_email.html feat(auth): password reset & invite flows for web + admin (#34) (#37) 2026-04-22 17:43:57 +02:00
login_magic_link.html feat: complete system — web UI, all API endpoints, governance, admin, CLI commands 2026-03-27 16:52:22 +01:00
login_magic_link_sent.html feat: complete system — web UI, all API endpoints, governance, admin, CLI commands 2026-03-27 16:52:22 +01:00
marketplace.html fix(store): promote-on-approve looks up version_no by submission_id (live agnes-development bug) (#330) 2026-05-15 21:21:14 +02:00
marketplace_format_guide.html Curated marketplace enrichment via agnes-metadata.json + curator metadata (#234) 2026-05-09 17:01:37 +02:00
marketplace_guide.html feat(marketplace): rename CTA + expand submit-flow guides (#308) 2026-05-14 19:44:33 +02:00
marketplace_item_detail.html feat(marketplace): telemetry v46 + flea inner parity + listing polish (#329) 2026-05-15 20:58:03 +02:00
marketplace_plugin_detail.html feat(marketplace): telemetry v46 + flea inner parity + listing polish (#329) 2026-05-15 20:58:03 +02:00
me_activity.html fix(web): render <strong> in /me/activity hero subtitle instead of escaping it (#312) 2026-05-14 22:27:34 +02:00
news.html feat(home): state-aware /home + /setup-advanced + schema v26 (#228) 2026-05-08 18:28:47 +02:00
password_reset.html feat(auth): password reset & invite flows for web + admin (#34) (#37) 2026-04-22 17:43:57 +02:00
password_setup.html feat(auth): password reset & invite flows for web + admin (#34) (#37) 2026-04-22 17:43:57 +02:00
profile.html feat(web): consolidate the personal /me/* surface — /me/activity + /me/profile (#304) 2026-05-14 21:29:51 +02:00
setup.html feat(setup): configurable instance brand + connector setup overhaul (#268) 2026-05-12 17:10:08 +02:00
setup_advanced.html feat(home): Getting Started + Overview + Usage modes sections (release 0.54.7) (#291) 2026-05-13 21:44:11 +02:00
store_edit.html fix(store-upload): Next/Back/Finish buttons missing .btn base class (#310) 2026-05-14 19:49:13 +00:00
store_examples.html feat(store-guardrails): admin-configurable content thresholds (#281) 2026-05-13 09:20:55 +00:00
store_upload.html fix(store-upload): Next/Back/Finish buttons missing .btn base class (#310) 2026-05-14 19:49:13 +00:00