Type check standard context
StandardContext
Possible issues that we should consider addressing in- How would we handle
namespace
being mistakenly passed in as aproject
?- since project responds to actual_plan_name it would be fine, but then our
namespace
value could match ourproject
value if initialized asStandardContext.new(namespace: project, project: project)
- since project responds to actual_plan_name it would be fine, but then our
- Should we type check
namespace
,project
, anduser
here so we don't run into possible error conditions like below if object doesn't respond toactual_plan_name
and other possible issues like in the 1st question?NoMethodError: undefined method `actual_plan_name' for 1:Integer
The following discussion from !75146 (merged) should be addressed:
-
@mikolaj_wawrzyniak started a discussion: (+3 comments) suggestion: Namespace the same as user expects to be provided with object that responds to
#id
call. Only project has implemented fallback and is able to accept both model objects and integers. https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/tracking/standard_context.rb#L48
/cc @gitlab-org/growth/product-intelligence @jejacks0n
Testing
Update related unit tests and make sure QA pipelines are passing
Edited by Carlo Catimbang