backstage: ๐Ÿ› Bug Report: 413 when too many entities are assigned

๐Ÿ“œ Description

When a user is owner of too many entities (in my case groups) the corresponding JWT Token is growing too big and the browser is rejecting these Requests with a 413.

๐Ÿ‘ Expected behavior

TBH Iโ€™m not quite sure what Iโ€™m expecting. Maybe some Docs on how to increase the maximum header size because Backstage itself canโ€™t mitigate this.

๐Ÿ‘Ž Actual Behavior with Screenshots

Chrome DevTools show that each request is rejected with a 413 (Request headers too large) Will add screenshots after creating of the issue

๐Ÿ‘Ÿ Reproduction steps

I had a custom gitlab instance and used the gpt from GitLab to create 1000 Groups. What I didnโ€™t think about was that my user is now owner of all of them and the GitLab Discovery is creating Backstage groups for all of them. Probably someone donโ€™t need GitLab to reproduce this and could just create 1000 Group Entities via a Groups.yaml.

๐Ÿ“ƒ Provide the context for the Bug.

I wasnโ€™t able to use backstage anymore as any request was failing

๐Ÿ–ฅ๏ธ Your Environment

OS:   Darwin 22.6.0 - darwin/arm64
node: v18.18.0
yarn: 3.6.1
cli:  0.22.13 (installed)
backstage:  1.18.1

Dependencies:
  @backstage/app-defaults                                          1.4.3
  @backstage/backend-app-api                                       0.5.3
  @backstage/backend-common                                        0.19.5
  @backstage/backend-defaults                                      0.2.3
  @backstage/backend-dev-utils                                     0.1.1
  @backstage/backend-openapi-utils                                 0.0.4
  @backstage/backend-plugin-api                                    0.6.3
  @backstage/backend-tasks                                         0.5.8
  @backstage/catalog-client                                        1.4.4
  @backstage/catalog-model                                         1.4.2
  @backstage/cli-common                                            0.1.12
  @backstage/cli-node                                              0.1.4
  @backstage/cli                                                   0.22.13
  @backstage/config-loader                                         1.5.0
  @backstage/config                                                1.1.0
  @backstage/core-app-api                                          1.10.0
  @backstage/core-components                                       0.13.5
  @backstage/core-plugin-api                                       1.6.0
  @backstage/dev-utils                                             1.0.21
  @backstage/errors                                                1.2.2
  @backstage/eslint-plugin                                         0.1.3
  @backstage/integration-aws-node                                  0.1.6
  @backstage/integration-react                                     1.1.19
  @backstage/integration                                           1.7.0
  @backstage/plugin-api-docs                                       0.9.11
  @backstage/plugin-app-backend                                    0.3.51
  @backstage/plugin-app-node                                       0.1.3
  @backstage/plugin-auth-backend-module-gcp-iap-provider           0.1.0
  @backstage/plugin-auth-backend-module-github-provider            0.1.0
  @backstage/plugin-auth-backend-module-gitlab-provider            0.1.0
  @backstage/plugin-auth-backend-module-google-provider            0.1.0
  @backstage/plugin-auth-backend-module-oauth2-provider            0.1.0
  @backstage/plugin-auth-backend                                   0.19.0
  @backstage/plugin-auth-node                                      0.3.0
  @backstage/plugin-catalog-backend-module-gitlab                  0.3.0
  @backstage/plugin-catalog-backend-module-scaffolder-entity-model 0.1.0
  @backstage/plugin-catalog-backend-module-unprocessed             0.3.0
  @backstage/plugin-catalog-backend                                1.13.0
  @backstage/plugin-catalog-common                                 1.0.16
  @backstage/plugin-catalog-graph                                  0.2.36
  @backstage/plugin-catalog-import                                 0.10.0
  @backstage/plugin-catalog-node                                   1.4.4
  @backstage/plugin-catalog-react                                  1.8.4
  @backstage/plugin-catalog                                        1.13.0
  @backstage/plugin-events-node                                    0.2.12
  @backstage/plugin-explore-common                                 0.0.2
  @backstage/plugin-github-actions                                 0.6.5
  @backstage/plugin-home-react                                     0.1.3
  @backstage/plugin-home                                           0.5.8
  @backstage/plugin-kubernetes-backend                             0.12.0
  @backstage/plugin-kubernetes-common                              0.6.6
  @backstage/plugin-kubernetes                                     0.10.3
  @backstage/plugin-org                                            0.6.14
  @backstage/plugin-permission-backend                             0.5.26
  @backstage/plugin-permission-common                              0.7.8
  @backstage/plugin-permission-node                                0.7.14
  @backstage/plugin-permission-react                               0.4.15
  @backstage/plugin-proxy-backend                                  0.4.0
  @backstage/plugin-scaffolder-backend-module-gitlab               0.2.6
  @backstage/plugin-scaffolder-backend                             1.17.0
  @backstage/plugin-scaffolder-common                              1.4.1
  @backstage/plugin-scaffolder-node                                0.2.3
  @backstage/plugin-scaffolder-react                               1.5.5
  @backstage/plugin-scaffolder                                     1.15.0
  @backstage/plugin-search-backend-module-catalog                  0.1.7
  @backstage/plugin-search-backend-module-explore                  0.1.7
  @backstage/plugin-search-backend-module-pg                       0.5.12
  @backstage/plugin-search-backend-module-techdocs                 0.1.7
  @backstage/plugin-search-backend-node                            1.2.7
  @backstage/plugin-search-backend                                 1.4.3
  @backstage/plugin-search-common                                  1.2.6
  @backstage/plugin-search-react                                   1.7.0
  @backstage/plugin-search                                         1.4.0
  @backstage/plugin-tech-radar                                     0.6.8
  @backstage/plugin-techdocs-backend                               1.7.0
  @backstage/plugin-techdocs-module-addons-contrib                 1.1.0
  @backstage/plugin-techdocs-node                                  1.8.0
  @backstage/plugin-techdocs-react                                 1.1.11
  @backstage/plugin-techdocs                                       1.7.0
  @backstage/plugin-user-settings                                  0.7.10
  @backstage/release-manifests                                     0.0.10
  @backstage/test-utils                                            1.4.3
  @backstage/theme                                                 0.4.2
  @backstage/types                                                 1.1.1
  @backstage/version-bridge                                        1.0.5

``
`

### ๐Ÿ‘€ Have you spent some time to check if this bug has been raised before?

- [X] I checked and didn't find similar issue

### ๐Ÿข Have you read the Code of Conduct?

- [X] I have read the [Code of Conduct](https://github.com/backstage/backstage/blob/master/CODE_OF_CONDUCT.md)

### Are you willing to submit PR?

No, but I'm happy to collaborate on a PR with someone else

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 3
  • Comments: 27 (20 by maintainers)

Commits related to this issue

Most upvoted comments

For anyone tracking this:

As part of the large auth improvements work thatโ€™s underway right now, weโ€™re moving the ownership refs out of the tokens and exposing them via a userInfo endpoint instead for those who need it. This will make the tokens fixed size and fix this issue once and for all. But itโ€™ll be a bit longer until that lands.

Iโ€™ll mention that in last Tuesdayโ€™s -next release, a flag was added that lets you opt in to exclude the large claim from your tokens.

Even after doing that, there are some cases where you can still hit limits. For example on the regular /catalog page if you have Owned selected, the size of the outgoing requests (filter complexity) scale with the number of refs too. Thereโ€™s still a ton of value in keeping the number of refs as low as possible, both for performance and security and reliability reasons.

Any update on this topic? I encountered the same issue. For me, the use case is that the admins of GitLab (who own 1000s of groups) are also the admins of Backstage. This means those admins cannot log into a tool they are responsible for (while normal users can since they own a reasonable number of groups).