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

Getting domains fails with "undefined method 'organization' for nil:NilClass" #2335

Closed
philippthun opened this issue Jun 11, 2021 · 0 comments · Fixed by #2396
Closed

Getting domains fails with "undefined method 'organization' for nil:NilClass" #2335

philippthun opened this issue Jun 11, 2021 · 0 comments · Fixed by #2396

Comments

@philippthun
Copy link
Member

Issue

Requests to /v3/domains and /v3/organizations/:org_guid/domains fail when user has a space-scoped role and one of the spaces for this role is deleted in parallel to handling one of the above requests.

Context

Getting readable orgs for space-scoped roles involves multiple database queries (i.e. first getting the space guids and then getting the org guid for each space). The current implementation cannot handle the situation when Space.find returns nil. This results in the following error: undefined method 'organization' for nil:NilClass leading to an HTTP 500 returned by cloud controller.

Steps to Reproduce

It's hard to reproduce, as it happens on huge foundations when there are users with access to many spaces and spaces getting deleted quite frequently (e.g. during some integration tests). It is possible to simulate the error in a debugger though (i.e. halt execution and delete rows from the database).

Expected result

Spaces that are gone should just be ignored.

Possible Fix

Use the safe navigation operator as done for the other <Model>.find occurrences in permissions.rb.

philippthun added a commit to sap-contributions/cloud_controller_ng that referenced this issue Jun 11, 2021
sweinstein22 added a commit that referenced this issue Jul 13, 2021
#2396)

* Fix unsafe navigation from non-existing space to org

Fixes #2335
bepotts pushed a commit that referenced this issue Jul 19, 2021
#2396)

* Fix unsafe navigation from non-existing space to org

Fixes #2335
sweinstein22 added a commit that referenced this issue Jul 22, 2021
#2396)

* Fix unsafe navigation from non-existing space to org

Fixes #2335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants