Provide context when logging unpermitted parameters#41809
Merged
rafaelfranca merged 1 commit intorails:mainfrom Apr 1, 2021
Merged
Provide context when logging unpermitted parameters#41809rafaelfranca merged 1 commit intorails:mainfrom
rafaelfranca merged 1 commit intorails:mainfrom
Conversation
cadd005 to
d83c83b
Compare
This was referenced Mar 31, 2021
Currently, the payload of the unpermitted_parameters.action_controller events emitted by StrongParameters does not provide enough information for developers to understand which controller and action received the unpermitted parameters. This PR modifies ActionController::Parameters to allow callers to specify a "context" which is included in the logging payload. *Implementation Strategy* Since the ActionController::Parameters class is only loosely coupled with controllers and can technically be used in any context, this PR expects the caller to provide logging context. Since StrongParameters is caller in Rails and has access to the request object I chose to provide a payload similar to the start_processing.action_controller event.
13554c6 to
6be9c49
Compare
hidr0
reviewed
Jun 17, 2021
| | `:keys` | Unpermitted keys | | ||
| | Key | Value | | ||
| | ------------- | --------------------------------------------------------------------- | | ||
| | `:key` | The unpermitted keys | |
There was a problem hiding this comment.
Should this be :key or keys? Why does it change from before?
Member
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.
Currently, the payload of the
unpermitted_parameters.action_controllerevents emitted by
StrongParametersdoes not provide enough information fordevelopers to understand which controller and action received the
unpermitted parameters. This PR modifies
ActionController::Parameterstoallow callers to specify a "context" which is included in the logging
payload.
Implementation Strategy
Since the
ActionController::Parametersclass is only loosely coupledwith controllers and can technically be used in any context, this PR
expects the caller to provide logging context.
Since
StrongParametersis the caller in Rails and has access to therequestobject I chose to provide a payload similar to thestart_processing.action_controller event.