Skip to content

fix: trim whitespace from API keys and host config#126

Merged
marandaneto merged 6 commits intomainfrom
fix/trim-whitespace-in-config-keys-and-host
Apr 21, 2026
Merged

fix: trim whitespace from API keys and host config#126
marandaneto merged 6 commits intomainfrom
fix/trim-whitespace-in-config-keys-and-host

Conversation

@marandaneto
Copy link
Copy Markdown
Member

💡 Motivation and Context

This ports the whitespace-trimming fix from posthog-go to posthog-php. It trims surrounding spaces and line breaks from the project API key, personal API key, and host before using them so the SDK does not silently send invalid tokens or build broken endpoints from whitespace-polluted configuration.

💚 How did you test it?

  • ./vendor/bin/phpunit --do-not-fail-on-warning --do-not-fail-on-deprecation --do-not-fail-on-phpunit-warning --do-not-fail-on-phpunit-deprecation --filter 'testClientTrimsWhitespaceSensitiveConfig|testClientLogsWhenApiKeyIsEmptyAfterTrimmingWhitespace|testInitDefaultsBlankHostAfterTrimmingWhitespace|testWhitespacePersonalApiKeyFallsBackToFlagsEndpoint'

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Added the release label to the PR
  • Added exactly one version bump label: bump-patch, bump-minor, or bump-major

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@marandaneto marandaneto merged commit a6ac54a into main Apr 21, 2026
15 checks passed
@marandaneto marandaneto deleted the fix/trim-whitespace-in-config-keys-and-host branch April 21, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants