Skip to content

Feature Flags: Add Remote config to Java SDK #577

Open

Description

@phillram

Feature request

Is your feature request related to a problem?

  • Currently only the Node.js, Python, Go, Ruby, & C# SDK's can use Remote Configs.
  • Java doesn't appear to have this functionality.

Describe the solution you'd like

  • It would be great to add remote config to the Java SDK.

Describe alternatives you've considered

  • At the moment you can construct flag calls for similar functionality, but this would be for parity.

Additional context

Debug info

Session: https://us.posthog.com/project/sTMFPsFhdP1Ssg/replay/019ecc7d-da51-798a-9dff-4036955dba94?t=17935
Admin (internal): http://go/adminOrgUS/019c4ed6-add0-0000-998a-30c999608349 (project ID 311650)

Activity

  1. marandaneto commented on Jun 16, 2026

    @marandaneto
    Member

    this is about the getRemoteConfigPayload method and not the /$token/config endpoint

  2. Miguel-Shinyenyi commented on Oct 14, 2026

    @Miguel-Shinyenyi

    Use case: a JVM backend reads the payload of a remote config flag (settings, or encrypted values that PostHog decrypts) without a user context. Node.js and Python have getRemoteConfigPayload. posthog-server has nothing equivalent. evaluateFlags() and getFeatureFlagPayload() both need a distinct id.

    Proposal, matching Node.js and Python:

    // PostHogInterface
    public fun getRemoteConfigPayload(key: String): Any?
    • Request: GET /api/projects/@current/feature_flags/{key}/remote_config?token={projectToken} with Authorization: Bearer {personalApiKey}. Node.js and Python send the same request.
    • Key: the existing personalApiKey in PostHogConfig, the one local evaluation uses. No new option.
    • Return: the decoded JSON payload, or null.
    • Errors: logged through the config logger and returned as null, like the flag code.
    • Where: a new method on the internal PostHogApi, next to localEvaluation.

    No existing option covers this. remoteConfig in PostHogConfig is a deprecated no-op, and PostHogApi.remoteConfig() calls the client /config endpoint.

    Questions:

    1. Are the name and signature right?
    2. With no personal API key, should it log and return null (Python) or throw (Node.js)?
    3. Should API errors reach the caller? null also means "no payload".
    4. Do you want an sdk-specs entry first?

    I can implement this once you agree on the shape.

  3. ioannisj commented on Nov 13, 2026

    @ioannisj
    Contributor

    Hey @Miguel-Shinyenyi, thanks for writing this up, the shape matches what I landed on. I'm working on it now in #978 (still a draft), so no need to pick it up.

    On your third question, errors would be logged and come back as null. A failed request, a non-2xx status and a body that isn't valid JSON each log a warning. A flag with no payload returns null with no warning, so the log is how you tell the two apart. Let me know if this would be a problem for your use case?

  4. huchenhai commented on Nov 13, 2026

    @huchenhai

    Just a suggestion, maybe nice to have,
    I think it might be good to have an addtional configuration option for remote config intervals which indepently from default polling 30s.
    Since remote config are something less frequently changed. Is that possible to have independent polling interval config
    for the remote config option?
    So I can set interval for config polling maybe every 5min. And keep user specific feature flag as default polling 30 seconds

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions