Skip to content

Comments

feat(flags): Add method for fetching decrypted remote config flag payload#180

Merged
havenbarnes merged 17 commits intomasterfrom
feat/encrypted-flag-payloads
Feb 13, 2025
Merged

feat(flags): Add method for fetching decrypted remote config flag payload#180
havenbarnes merged 17 commits intomasterfrom
feat/encrypted-flag-payloads

Conversation

@havenbarnes
Copy link
Contributor

@havenbarnes havenbarnes commented Feb 8, 2025

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds functionality to fetch decrypted remote config flag payloads through new methods in the PostHog Python client, enabling secure access to flag configurations.

  • New remote_config function in /posthog/request.py needs correction in success message and parameter validation
  • Added get_decrypted_feature_flag_payload method in /posthog/__init__.py requires improved documentation for parameters and return types
  • Implemented get_remote_config_payload in /posthog/client.py with personal API key validation and error handling
  • API endpoint path construction in /posthog/request.py could be improved for better clarity
  • Missing type hints for new methods across all modified files

3 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 83 to 85
def remote_config(api_key: str, host: Optional[str] = None, flag_id: str = "", timeout: int = 15) -> Any:
res = get(api_key, host, f"/api/projects/@current/feature_flags/{flag_id}/remote_config/", timeout)
return _process_response(res, success_message="Feature flags decided successfully")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Success message should be specific to remote config, e.g. 'Remote config fetched successfully' instead of reusing 'Feature flags decided successfully'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with greptile here

havenbarnes and others added 6 commits February 10, 2025 12:32
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@haacked
Copy link
Collaborator

haacked commented Feb 11, 2025

Just so I understand, decryption always happens on the server, correct? And it looks like there's an API endpoint to get a single decrypted setting, but not a way to get all of them?

@havenbarnes
Copy link
Contributor Author

Just so I understand, decryption always happens on the server, correct?

Correct!

And it looks like there's an API endpoint to get a single decrypted setting, but not a way to get all of them?

Yes, the /remote_config endpoint is intended for single decrypted settings. However our GET /feature_flags ("list all flags") endpoint would also decrypt feature flags for you if you were authenticated with a personal API key, so you could get all of them at once if you wanted to

havenbarnes and others added 5 commits February 12, 2025 10:17
@havenbarnes havenbarnes merged commit 6764c78 into master Feb 13, 2025
6 checks passed
@havenbarnes havenbarnes deleted the feat/encrypted-flag-payloads branch February 13, 2025 22:21
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.

4 participants