Skip to content

REST 404s return generic "Resource Not found" and drop abort() descriptions #1020

Description

@shiwani42

Issue

What is the issue?

application/web/web_main.py registers a global 404 handler that always returns the plain string "Resource Not found". Flask abort(404, "…") descriptions never reach the client.

That includes abort(404, "No such Cache") on production/Heroku map_analysis cache miss, and abort(404, "No object matches the given search terms") on empty text_search.

The Gap Analysis UI reads e.response.data.message. For a string body that field is missing, so the page shows axios’s generic “Request failed with status code 404”.

abort(400/401/503) are unaffected (no custom handlers).

Expected Behaviour

A REST abort(404, "No such Cache") should surface that text to API clients, e.g. JSON {"message": "No such Cache"} for /rest/v1/*. Non-API 404s can stay a simple page.

Actual Behaviour

Every 404 body is "Resource Not found".

Steps to reproduce

  1. Flask test client, HEROKU=True, cache miss:
    GET /rest/v1/map_analysis?standard=OpenCRE&standard=NIST%20800-53%20v5
  2. Status is 404 (existing test already checks this).
  3. Body is "Resource Not found", not "No such Cache".

Same wipe: GET /rest/v1/text_search?text=no-such-term → 404 "Resource Not found".

Success criteria

  • /rest/v1/* 404 responses include the abort() description (JSON message is enough for the Gap Analysis UI).
  • Test asserts Heroku/cache-miss map_analysis body contains No such Cache.
  • make lint / make mypy / make test green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions