Allow organization feature actor by ID or path

What does this MR do and why?

Follow-up to !243125 (merged) (see !243125 (comment 3510365608)).

The features API accepted organizations as actors by ID only. This copies the existing project actor behaviour so an organization can also be targeted by its path, making the parameter consistent with how other path-addressable actors are resolved.

def organizations
  find_targets(:organization) do |arg|
    if arg.match?(/\A\d+\z/)
      Organizations::Organization.find_by_id(arg)
    else
      Organizations::Organization.find_by_path(arg)
    end
  end
end

How to set up and validate locally

# Enable a feature flag for an organization by path
curl --request POST --header "PRIVATE-TOKEN: <token>" \
  --data "value=true&organization=default" \
  "https://gitlab.example.com/api/v4/features/my_feature"

# Mix IDs and paths
curl --request POST --header "PRIVATE-TOKEN: <token>" \
  --data "value=true&organization=1,default" \
  "https://gitlab.example.com/api/v4/features/my_feature"

MR acceptance checklist

  • Tests added for new functionality (spec/lib/feature_spec.rb, spec/requests/api/features_spec.rb)
  • API docs updated (doc/api/features.md gained the missing organization row)
  • OpenAPI documentation regenerated

Note

Targets the parent branch feature/api-features-organization-actor; retarget to master once 243125 merges.

🤖 Generated with Claude Code

Merge request reports

Loading
Loading