Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix groupByNameAndOrganization resolver errors when group not found #3800

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rocketeerbkw
Copy link
Member

General Checklist

  • Affected Issues have been mentioned in the Closing issues section
  • Documentation has been written/updated
  • PR title is ready for inclusion in changelog

Database Migrations

  • If your PR contains a database migation, it MUST be the latest in date order alphabetically

When attempting to load a group by name and org ID, and the group either doesn't exist, or is not a part of the organization, AND the members field is requested, a cryptic error would be thrown:

{
  "errors": [
    {
      "message": "keycloakGroups is not iterable",
      "locations": [
        {
          "line": 5,
          "column": 4
        }
      ],
      "path": [
        "groupByNameAndOrganization",
        "members"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: keycloakGroups is not iterable",
            "    at /app/services/api/dist/models/group.js:358:37",
            "    at Generator.next (<anonymous>)",
            "    at fulfilled (/app/services/api/dist/models/group.js:28:58)",
            "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
          ]
        }
      }
    }
  ],
  "data": {
    "groupByNameAndOrganization": {
      "id": null,
      "name": null,
      "members": null
    }
  }
}

This is because the resolver returns groupS but the schema expects a single group. Returning an empty array still calls the members resolver, which can't get any information for an undefined group and fails.

This PR changes the return value to be a single group, and throws a normal GroupNotFoundError.

This was broken before the keycloak upgrade refactor but the base branch is that to help with merge conflicts. Can wait to merge after keycloak upgrade.

@rocketeerbkw rocketeerbkw force-pushed the keycloak-upgrade branch 2 times, most recently from 66d592a to d7a076f Compare September 4, 2024 12:14
Base automatically changed from keycloak-upgrade to main September 4, 2024 23:12
@shreddedbacon
Copy link
Member

@rocketeerbkw is this something that needs to be in v2.21.0?

@rocketeerbkw rocketeerbkw force-pushed the fix-groupByNameAndOrganization branch from 200e0fd to 52c45e1 Compare September 9, 2024 19:58
@rocketeerbkw rocketeerbkw marked this pull request as ready for review September 9, 2024 19:59
@rocketeerbkw
Copy link
Member Author

This doesn't need to hold up v2.21.0.

@rocketeerbkw rocketeerbkw added this to the 2.22.0 milestone Oct 31, 2024
@tobybellwood tobybellwood modified the milestones: 2.22.0, 2.23.0 Nov 17, 2024
@tobybellwood tobybellwood removed this from the 2.23.0 milestone Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants