task: implement header symbolization with opt-out configuration#42
Merged
Conversation
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] task: header symbolization
task: implement header symbolization with opt-out configuration
Jun 13, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds header symbolization to webhook handlers with opt-out configuration, ensuring headers are consistent with other symbolized parameters.
- Introduces
symbolize_headersutility and integrates it into the request handling flow. - Extends the config loader with a new
symbolize_headersoption (defaulttrue) and correspondingHOOKS_SYMBOLIZE_HEADERSenvironment variable. - Updates documentation and tests (unit and integration) to cover header symbolization behavior.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| spec/unit/lib/hooks/plugins/utils/normalize_spec.rb | Added unit tests covering symbolize_headers for various inputs |
| spec/unit/lib/hooks/core/config_loader_spec.rb | Updated config loader specs to include symbolize_headers default and opt-out |
| spec/integration/header_symbolization_spec.rb | Added end-to-end integration tests for header symbolization |
| lib/hooks/utils/normalize.rb | Implemented Normalize.symbolize_headers and added YARD docs |
| lib/hooks/plugins/handlers/base.rb | Updated handler base class docs to reflect symbolized headers |
| lib/hooks/core/config_loader.rb | Added symbolize_headers to default config and env mapping |
| lib/hooks/app/api.rb | Integrated symbolization into API request processing |
| docs/handler_plugins.md | Expanded documentation to describe header symbolization and opt-out |
| .bundle/config | Bundler config paths updated (review portability) |
Comments suppressed due to low confidence (4)
lib/hooks/utils/normalize.rb:64
- Update the @return annotation to reflect that
symbolize_headersmay returnnilfornilinput or an empty Hash for non-enumerable inputs (e.g.,@return [Hash, nil]).
@return [Hash] Hash with symbolized keys (hyphens converted to underscores)
lib/hooks/plugins/handlers/base.rb:18
- [nitpick] Consider refining the type annotation to something like
Hash<Symbol, Object>to clarify that keys are symbols and values can be strings, arrays, booleans, etc.
# @param headers [Hash] HTTP headers (symbolized keys by default)
docs/handler_plugins.md:100
- [nitpick] There's duplicate guidance on disabling symbolization and normalization nearby; consider consolidating these instructions for clarity and to avoid repetition.
You can disable header symbolization by either setting the environment variable `HOOKS_SYMBOLIZE_HEADERS` to `false` or by setting the `symbolize_headers` option to `false` in the global configuration file.
.bundle/config:3
- The Bundler config contains an absolute CI path, which can hinder portability; consider reverting to a project-local or relative path, or omitting
.bundle/configfrom version control.
BUNDLE_PATH: "/home/runner/work/hooks/hooks/vendor/bundle"
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.
This PR implements header symbolization for webhook handlers, following the same pattern as payload symbolization. Headers are now symbolized by default with hyphens converted to underscores, making them consistent with other symbolized parameters.
Changes Made
Core Implementation
symbolize_headers: trueto default configurationHOOKS_SYMBOLIZE_HEADERSenvironment variable for opt-outHooks::Utils::Normalize.symbolize_headersmethod that converts header keys to symbols and replaces hyphens with underscoresExample Transformation
Opt-out Options
Users can disable header symbolization via:
HOOKS_SYMBOLIZE_HEADERS=falsesymbolize_headers: falseDocumentation Updates
docs/handler_plugins.mdwith new symbolized headers behaviorTesting
Backward Compatibility
Fixes #41.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.