Skip to content

Use type instead of name to detect secret integration fields

Summary

The integration form has some logic to handle "secret" fields, so you only have to enter a value when you want to change it, and otherwise the previous value is preserved.

This is handled on the frontend by checking if the type of the field is set to password: https://gitlab.com/gitlab-org/gitlab/blob/2b93237446889e5a910d0796351beccc1dded6fc/app/assets/javascripts/integrations/edit/components/dynamic_field.vue#L68

But on the backend we instead check if the name of the field is password: https://gitlab.com/gitlab-org/gitlab/blob/2b93237446889e5a910d0796351beccc1dded6fc/app/controllers/concerns/service_params.rb#L81

This came up in the Datadog integration, where we have a secret field called api_key. This has the side-effect that the user always has to reenter the api_key when making changes.

Improvements

Align the backend code to also check for the field type, instead of hard-coding the field name.

This should be straightforward since we already have access to the current @service instance in the service_params method.

Involved components

  • app/controllers/concerns/service_params.rb

Optional: Intended side effects

This should fix the password-clearing behaviour in the Datadog integration.

Edited by Markus Koller