Repository navigation
Fixes #39718 - Fix NoMethodError when taxonamy passed to images API - #11215
Merged
Merged
Conversation
Member
|
@nacoool can you please fix the rubocop issues and add a redmine? |
nacoool
force-pushed
the
fix_taxonomy_cr_azure_image
branch
2 times, most recently
from
August 31, 2026 14:18
1405ada to
1c56701
Compare
nacoool
force-pushed
the
fix_taxonomy_cr_azure_image
branch
from
August 31, 2026 16:49
1c56701 to
2d142b5
Compare
…sed to images API
nacoool
force-pushed
the
fix_taxonomy_cr_azure_image
branch
from
September 2, 2026 05:46
2d142b5 to
289994d
Compare
Member
|
It is a bit unclear to me how do I reproduce the issue, is it just |
lzap
self-requested a review
September 3, 2026 14:00
Member
|
Reproduced: Taking a closer look. |
lzap
approved these changes
Sep 4, 2026
lzap
left a comment
Member
There was a problem hiding this comment.
Tested, image created with this.
I see no security implications. The only concern I have is how to prevent such issues in the future when we implement a nested controller.
Contributor
|
This has caused a regression: https://redhat.atlassian.net/browse/SAT-52699 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
organization_idorlocation_idare passed as top-level parameters to the images API (e.g., via hammer compute-resource image create), they were incorrectly being used as the nested parent object instead of compute_resource_id, causing a NoMethodError:NoMethodError: undefined method 'images' for #<Organization id: 1, name: "NAME"...>
This occurred because parent_resource_details in base_controller.rb was iterating over all parameters ending with _id, rather than only those explicitly allowed via allowed_nested_id.
Root Cause
In app/controllers/api/base_controller.rb, the parent_resource_details method was selecting all params ending with _id:
params.select { |param| param.ends_with?('_id') }.each do |param, value|This meant that
organization_idandlocation_idcould be selected as the parent resource before compute_resource_id, leading to the controller trying to call .images on an Organization or Location object (which don't have that association).Solution
Modified parent_resource_details to only consider parameters that are explicitly listed in the controller's
allowed_nested_id method:params.select { |param| allowed_nested_id.include?(param.to_s) }.each do |param, value|This ensures that only valid nested resource IDs are used as parent objects.