fix(admin): encrypt only after successful validation#13729
Merged
shreemaan-abhishek merged 1 commit intoJul 23, 2026
Merged
Conversation
check_conf ran the encrypt_conf hook before checking the checker result, so malformed input (e.g. a non-object plugins value) reached pairs() in the plugin encrypt hook and turned a 400 schema error into a 500. Move encryption below the 'if not ok' return so it runs only on validated config. Also drop the check_schema gate in plugin_metadata.encrypt_conf so a plugin that validates via core.schema.check does not skip metadata secret encryption. Adds t/admin/encrypt-after-validation.t: invalid plugins -> 400 (not 500); valid config still encrypts a secret field at rest.
nic-6443
approved these changes
Jul 23, 2026
AlinsRan
approved these changes
Jul 23, 2026
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.
Description
resource.check_confcalls the per-resourceencrypt_confhook before checking whetherself.checker(...)succeeded. For invalid input, the encryption hooks therefore run against unvalidated structures: for example, a non-objectpluginsvalue reachespairs(plugins_conf)inadmin/plugins.luaand raises a Lua error, turning a clean 400 schema-validation error into a 500.This moves the
encrypt_confcall below theif not ok then returnso encryption runs only on validated config (invalid configs are never persisted anyway).Also drops the
plugin_object.check_schemagate inplugin_metadata.encrypt_conf:plugin.encrypt_confderives fields frommetadata_schema.encrypt_fieldsand does not need a custom validator, so a plugin that validates viacore.schema.checkwould otherwise skip encryption and persist its metadata secret in plaintext.Both were introduced in #12603.
Tests
New
t/admin/encrypt-after-validation.t:pluginsvalue now returns 400 (previously a 500 frombad argument #1 to 'pairs' (table expected, got string));key-authsecret is still stored as ciphertext at rest whendata_encryptionis enabled, confirming encryption still runs on the success path.Checklist
luacheck)