Skip to content

Error codes in TopicManagementResponse are incomplete, causing loss of important debug information #1072

Closed

Description

@JosRoseboom

[REQUIRED] Step 2: Describe your environment

  • Operating System version: MacOs 15.1.1 and docker from arm64v8/amazoncorretto:21-al2023-headless
  • Firebase SDK version: 9.4.3
  • Library version: firebase-admin-java
  • Firebase Product: firebase-admin

[REQUIRED] Step 3: Describe the problem

TopicManagementResponse has currently 4 error codes:

  private static final Map<String, String> ERROR_CODES = ImmutableMap.<String, String>builder()
      .put("INVALID_ARGUMENT", "invalid-argument")
      .put("NOT_FOUND", "registration-token-not-registered")
      .put("INTERNAL", "internal-error")
      .put("TOO_MANY_TOPICS", "too-many-topics")

Looking at https://developers.google.com/instance-id/reference/server , I see that it is currently also possible that RESOURCE_EXHAUSTED is returned. We log the response if there are any errors and currently see a lot of:

[Error{index=0, reason=unknown-error}]

This is not helpful, while it could be caused by RESOURCE_EXHAUSTED, which would be really good to know.

The second problem is that the error string comes from :

 private Error(int index, String reason) {
      this.index = index;
this.reason = ERROR_CODES.containsKey(reason)
        ? ERROR_CODES.get(reason) : UNKNOWN_ERROR;

If the reason is not in the predefined ERROR_CODES it would be more helpful to use the reason String that came in as an parameter than UNKNOWN_ERROR. UNKNOWN_ERROR could be used for null or empty Strings.

Steps to reproduce:

Cause a RESOURCE_EXHAUSTED and see that the error description is unknown-error

Solution

I went ahead and patched this for our own use. I will create a PR containing a commit that adds RESOURCE_EXHAUSTED and a commit that uses the parameter reason as fallback in case of a non empty string.

Activity

  1. google-oss-bot commented on Feb 5, 2025

    @google-oss-bot

    I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

  2. JosRoseboom commented on Feb 5, 2025

    @JosRoseboom
    ContributorAuthor

    I created a pull request for this issue: #1073

  3. JosRoseboom commented on Nov 11, 2025

    @JosRoseboom
    ContributorAuthor

    Hi,

    i've created this issue with the ready to merge fix a while ago. Anyone available to triage this issue or review the pr? (#1073) @jonathanedey perhaps?

    Thanks,
    jos

  4. self-assigned this
    on Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions