Fix EncryptedValue handling in lookup adapters#25244
Open
danotorrey wants to merge 3 commits intomasterfrom
Open
Fix EncryptedValue handling in lookup adapters#25244danotorrey wants to merge 3 commits intomasterfrom
danotorrey wants to merge 3 commits intomasterfrom
Conversation
Add `prepareConfig` plugin hook to transform EncryptedValue fields
before they enter Formik state. This prevents the auto-validation
useEffect from sending raw `{"is_set": true}` to the server, which
fails deserialization.
The Formik migration in AdapterFormFields introduced a validation
useEffect that fires before child fieldset effects can convert
encrypted values. Moving the conversion to a synchronous useMemo
in AdapterForm ensures values are transformed before any validation.
The LookupTableResource.updateAdapter() method was saving adapter configs
directly without merging EncryptedValue fields. When the client sent
{"keep_value": true}, the value was lost because the existing encrypted
value was never fetched from the database.
Add prepareConfigUpdate() to LookupDataAdapterConfiguration following the
same pattern as EventNotificationConfig.prepareConfigUpdate(). Override it
in GreyNoiseQuickIPDataAdapter.Config to preserve api_token on update.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two issues when editing lookup data adapters with encrypted fields (API tokens, passwords):
Deserialization error on edit — Opening an existing adapter shows: "Couldn't deserialize value: {"is_set":true} (set_value must be a string and cannot be missing)" because a Formik validation race condition sends raw
{"is_set": true}to the server before the form can convert it.Encrypted values silently cleared on save — Saving an adapter without resetting its token/password clears the encrypted value to
{"is_set": false}because the backend never merges{"keep_value": true}with the existing DB record. This has existed since adapters first used EncryptedValue (~2021).Affects all adapters with encrypted fields: GreyNoise Quick IP (
api_token), GreyNoise Full IP (api_token), and LDAP (user_passwd).Frontend: Add
prepareConfigplugin hook to convert encrypted values synchronously before Formik initialization, preventing the race condition. Applied to GreyNoise Quick IP; removed LDAP-specific workaround fromAdapterTypeSelect.Backend: Add
prepareConfigUpdate()toLookupDataAdapterConfiguration(same pattern asEventNotificationConfig.prepareConfigUpdate()) and call it inLookupTableResource.updateAdapter()to merge encrypted values from the existing DB record. Override inGreyNoiseQuickIPDataAdapter.Config.See https://github.com/Graylog2/graylog-plugin-enterprise/pull/13445 for enterprise-side changes (GreyNoise Full IP + LDAP).
Test plan