-
Notifications
You must be signed in to change notification settings - Fork 0
task: default to JSON in and JSON out #62
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 <[email protected]>
Co-authored-by: GrantBirki <[email protected]>
Co-authored-by: GrantBirki <[email protected]>
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 changes the default request/response format of the Hooks webhook server from plain text to JSON, adds configuration and environment variable support for formats, and updates all endpoints, tests, and documentation accordingly.
- Introduces
format
anddefault_format
config options (default to:json
) withHOOKS_FORMAT
/HOOKS_DEFAULT_FORMAT
env var support. - Updates the main API and built-in endpoints (version, health, catchall) to use configurable JSON formatting instead of hardcoded text.
- Refactors tests with a new
expect_json_auth_failure
helper, updates acceptance tests for JSON responses, and documents the new options.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
spec/unit/lib/hooks/core/config_loader_spec.rb | Added tests for format /default_format defaults and env-var parsing |
spec/acceptance/acceptance_tests.rb | New expect_json_auth_failure helper; updated tests to use JSON output |
lib/hooks/core/config_loader.rb | Added format /default_format defaults and env-var conversion |
lib/hooks/app/endpoints/version.rb | Configured JSON content types and default format |
lib/hooks/app/endpoints/health.rb | Configured JSON content types and default format |
lib/hooks/app/endpoints/catchall.rb | Configured JSON content types/default format; removed manual .to_json |
lib/hooks/app/api.rb | Made format and default_format configurable via settings |
docs/configuration.md | Documented format and default_format options |
.bundle/config | CI-specific Bundler settings updated |
Comments suppressed due to low confidence (2)
.bundle/config:3
- This .bundle/config contains an environment-specific absolute path. Consider removing it from version control or using a relative path to avoid CI/local environment conflicts.
BUNDLE_PATH: "/home/runner/work/hooks/hooks/vendor/bundle"
spec/unit/lib/hooks/core/config_loader_spec.rb:203
- This test sets
ENV["HOOKS_FORMAT"]
andENV["HOOKS_DEFAULT_FORMAT"]
without cleaning them up. Consider using an around hook or resetting these env vars after the example to prevent side effects on other tests.
it "converts format environment variables to symbols" do
@copilot thank you for these changes! They look excellent and do exactly what I was after. One more thing though, please update the |
Co-authored-by: GrantBirki <[email protected]>
The Commit: 24217a4 |
This PR implements the breaking change to default the Hooks webhook server to JSON format for both input and output, replacing the previous plain text defaults.
Changes Made
Configuration Options
format
anddefault_format
configuration options that default to:json
HOOKS_FORMAT
andHOOKS_DEFAULT_FORMAT
API Updates
:txt
Authentication Responses
Authentication failures now return structured JSON responses instead of plain text:
Before:
After:
Test Updates
expect_json_auth_failure
for consistent JSON response validationDocumentation
format
anddefault_format
configuration optionsBreaking Changes
error!
calls with strings now return JSON-encoded strings for consistency:txt
to:json
Testing
Sample Usage
The server now defaults to JSON but can be configured:
Or via environment variables:
This change delivers on the "JSON in and JSON out" philosophy while maintaining configurability for edge cases.
Fixes #61.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.