Skip to content

listLayers API should return empty list instead of 400 when no layers exist #1849

Description

@shekhar316

Describe the bug
Currently, when calling the listLayers, listMetadataProfiles, listMetricProfiles API and no layers exist, the API responds with a 400 Bad Request.

Why this is problematic:

  • Unexpected error handling: Returning a 400 requires clients to handle an exception even when the request is technically valid. “No layers exist” is not an error, it is a legitimate state.
  • API design best practices: RESTful API design generally treats “no data” as a valid response, not an error. Returning an empty array is the standard approach for list endpoints.

Expected behavior

  • Update APIs to return [] (empty list) when no layers exist.
  • Ensure the response code is 200 OK to indicate a successful request.

Relevant logs

{
  "message": "No layers found!",
  "httpcode": 400,
  "documentationLink": "",
  "status": "ERROR"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions