Assign plan_id when building a new plan limit
What does this MR do?
In our documentation we are directing users to use Plan.default.limits.update!
to change the application limits but we are using Plan.default.actual_limits
to check these limits.
The problem with Plan.default.limits
is that it can be nil
, resulting in errors when trying to update a plan limit:
Plan.default.limits.update!(ci_instance_level_variables: 30)
Traceback (most recent call last):
1: from (irb):5
NoMethodError (undefined method `update!' for nil:NilClass)
And using Plan.default.actual_limits
in its actual form fails because the limit record is not linked to the plan:
Plan.default.actual_limits.update!(ci_instance_level_variables: 30)
Traceback (most recent call last):
1: from (irb):16
ActiveRecord::NotNullViolation (PG::NotNullViolation: ERROR: null value in column "plan_id" violates not-null constraint)
DETAIL: Failing row contains (1, null, 0, 0, 0, 100, 50, 2, 10, 50000, 30).
Workaround
Until this MR is deployed, plan limits can be updated using:
(Plan.default.limits || Plan.default.build_limits).update!(ci_instance_level_variables: 30)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Kamil Trzciński (Back 2025-01-01)