Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flags): Fix trailing comma in FeatureFlagSnippets #27861

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MaxHorstmann
Copy link

Problem

Small frontend documentation bug on Feature flags => "How to implement" => API:

image

The sample JSON payload contains a trailing comma, which the API rightfully rejects:

$ $ curl https://us.i.posthog.com/decide\?v=3/ \
-X POST -H 'Content-Type: application/json' \
-d '{
    "api_key": "ph...X",
    "distinct_id": "123",
}'

{"type": "validation_error", "code": "malformed_data", "detail": "Malformed request data: Invalid JSON: Expecting property name enclosed in double quotes: line 4 column 1 (char 94)", "attr": null}

Changes

Just updating the snippet so it removes the trailing comma (if there's no group addition).

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Confirmed that the snipped works without the trailing comma:

$ curl https://us.i.posthog.com/decide\?v=3/ \
-X POST -H 'Content-Type: application/json' \
-d '{
    "api_key": "phc...X",
    "distinct_id": "123" 
}'

{"config": {"enable_collect_everything": true}, "toolbarParams": {}, "isAuthenticated": false, "supportedCompression": ["gzip", "gzip-js"], "featureFlags": {"testFeatureFlag": true}, "sessionRecording": false, "captureDeadClicks": false, "capturePerformance": false, "autocapture_opt_out": false, "autocaptureExceptions": false, "analytics": {"endpoint": "/i/v0/e/"}, "elementsChainAsString": true, "surveys": false, "heatmaps": false, "flagsPersistenceDefault": false, "defaultIdentifiedOnly": true, "siteApps": []}

@Twixes Twixes requested a review from a team January 24, 2025 16:23
Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

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

nice catch, thank you!

@dmarticus dmarticus changed the title Fix trailing comma in FeatureFlagSnippets fix(flags): Fix trailing comma in FeatureFlagSnippets Jan 24, 2025
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.

2 participants