Report unsupported resource types in Orbit redaction
What does this MR do and why?
Orbit asks Authz::RedactionService which result rows a user can see. For a resource type that the service did not know, it returned false for every ID and logged nothing. A new Orbit node type that Rails did not register then returned empty results with no signal.
Now the service reports each unknown type before it loads any record.
- In development and test, it raises
UnsupportedResourceTypeError, so specs and GDK fail at once. - In production, it sends the error to error tracking and still denies those IDs. Orbit can be newer than Rails on Dedicated and self-managed. A hard error there would fail every query that touches the new type.
References
- gitlab-org/orbit/knowledge-graph#1313: new Orbit node types fail closed with no signal unless Rails registers them.
- gitlab-org/orbit/knowledge-graph#570: the Orbit side is in gitlab-org/orbit/knowledge-graph!2794 (closed) and gitlab-org/orbit/knowledge-graph!2795 (closed).
Screenshots or screen recordings
Not a UI change.
How to set up and validate locally
-
Run the specs. On master, the two new unsupported-type examples fail.
bundle exec rspec spec/services/authz/redaction_service_spec.rb \ ee/spec/services/ee/authz/redaction_service_spec.rb \ ee/spec/lib/analytics/knowledge_graph/query_runner_spec.rb \ ee/spec/requests/api/internal/orbit_redaction_spec.rb -
In a Rails console, run the service with a known type and an unknown type.
Authz::RedactionService.new( user: User.first, source: 'console', resources_by_type: { 'project' => { 'ids' => [1], 'ability' => 'read_project' }, 'widget' => { 'ids' => [1, 2], 'ability' => 'read_widget' } } ).execute # => Authz::RedactionService::UnsupportedResourceTypeError: unsupported resource_type: "widget"With
should_raise_for_dev?set to false, as in production, the same call returns{"project"=>{1=>true}, "widget"=>{1=>false, 2=>false}}, andlog/exceptions_json.loggets the error withextra.source.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.