Skip to content

Conversation

@tfriedel
Copy link

Summary

  • Add json:"-" tags to URL and Token fields in the ntfy Notification struct to exclude them from JSON serialization

Problem

When sending notifications to ntfy, the URL and Token fields were being included in the JSON payload. Some ntfy servers (particularly self-hosted instances) reject requests containing unknown fields in the JSON body with:

{"code":40024,"http":400,"error":"invalid request: request body must be valid JSON"}

Solution

The URL and Token fields are only needed for HTTP request configuration (URL endpoint and Authorization header), not for the JSON body. Adding json:"-" tags excludes them from json.Marshal() while keeping them available for the request.

Test plan

  • Verified fix works against a self-hosted ntfy server that was rejecting requests
  • go test ./service/ntfy/... passes

🤖 Generated with Claude Code

The URL and Token fields were being included in the JSON payload sent
to the ntfy server. Some ntfy servers reject requests with unknown
fields in the JSON body, returning a 400 error:
"invalid request: request body must be valid JSON"

Adding `json:"-"` tags excludes these fields from serialization while
keeping them available for the HTTP request configuration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant