Add validations to workspace_agentk_state.rb
MR: Pending
Description
The following discussion from !194727 (merged) should be addressed:
-
@cwoolley-gitlab started a discussion: question: WDYT of making a simple JSON validation for this field (see https://gitlab.com/gitlab-org/gitlab/-/blob/90252bbb3d9e854d26fd971fa43ebeb71c635546/ee/lib/remote_development/README.md#validation-strategy)
I know that we already validate this field thoroughly in the business logic, but that doesn't prevent something somewhere else from persisting something invalid in this field.
Given the variablility in this structure, it wouldn't validate everything. Maybe just the structure. E.g., that it is an array of objects with a
kind
andname
attribute.This doesn't have to be in this MR, it can be a follow-up issue.
Related
Acceptance criteria
TODO: Fill out (required)
-
[Describe what must be achieved to complete this issue.] -
[If applicable, please provide design specifications for this feature/enhancement.] -
[If applicable, please list any technical requirements (performance, security, database, etc.)]
Implementation plan
Rather than doing a direct duplicate logic of schema validation, lets just create a DesiredConfig
value object from the data and validate it before saving, then stick any errors found onto the WorkspaceAgentkState
desired_config
field. This should be sufficient, and won't keep the duplication.