-
Notifications
You must be signed in to change notification settings - Fork 3
task: implement header symbolization with opt-out configuration #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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.