Skip to content

fix: no-op setup without api key#503

Draft
marandaneto wants to merge 1 commit intomainfrom
fix/noop-empty-api-key
Draft

fix: no-op setup without api key#503
marandaneto wants to merge 1 commit intomainfrom
fix/noop-empty-api-key

Conversation

@marandaneto
Copy link
Copy Markdown
Member

@marandaneto marandaneto commented Apr 30, 2026

💡 Motivation and Context

Setup currently continued initializing after the API key trimmed to an empty string. Java callers could also pass a null Android API key and hit SDK init unexpectedly.

This changes null API keys to trim to an empty string and makes core/stateless setup return before initialization when the key is empty after trimming. Android setup skips Android-specific configuration for invalid keys.

💚 How did you test it?

  • ./gradlew :posthog:test --tests "com.posthog.PostHogConfigTest" --tests "com.posthog.PostHogStatelessTest" --tests "com.posthog.PostHogTest"
  • ./gradlew :posthog-android:testDebugUnitTest --tests "com.posthog.android.PostHogAndroidConfigTest" --tests "com.posthog.android.PostHogAndroidConfigJavaTest" --tests "com.posthog.android.PostHogAndroidTest"
  • make checkFormat
  • ./gradlew :posthog:apiCheck :posthog-android:apiCheck

📝 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 a changeset file for the affected packages
  • Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

@github-actions
Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-04-30 10:42:49 UTC
Duration: 461ms

⚠️ Some Tests Failed

0/1 tests passed, 1 failed


Feature_Flags Tests

⚠️ 0/1 tests passed, 1 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 278ms

Failures

request_payload.request_with_person_properties_device_id

404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant