Add validations to workspace_agentk_state.rb
MR: Pending <!-- NOTE: For context on MR heading, see: https://handbook.gitlab.com/handbook/engineering/devops/dev/create/remote-development/index.html#relationship-of-issues-to-mrs --> ## Description The following discussion from !194727 should be addressed: - [ ] @cwoolley-gitlab started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/194727#note_2599811673): > **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` and `name` attribute. > > This doesn't have to be in this MR, it can be a follow-up issue. ## Related - https://gitlab.com/gitlab-org/gitlab/-/issues/551799+s ## 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. <!-- NOTE: Feel free to expand with more sections and headers as needed --> <!-- DO NOT TOUCH BELOW -->
issue