:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(ci): read the split charts state file when rebuilding a flags canary (#107116)
Gustavo H. Strassburger4b542bd792e5
diff --git a/.github/workflows/canary-flags-enable.yml b/.github/workflows/canary-flags-enable.ymlindex ec6084c81ca0..f89afe72273d 100644--- a/.github/workflows/canary-flags-enable.yml+++ b/.github/workflows/canary-flags-enable.yml@@ -272,7 +272,7 @@ jobs:# Lightweight preflight: validate PR + resolve target_environment.# On `pull_request: synchronize`, target_environment comes from the active- # canary's state in PostHog/charts:state.yaml — NOT a hardcoded default.+ # canary's state in PostHog/charts:state/feature-flags.yaml — NOT a hardcoded default.# If the canary is disabled or owned by a different PR, should_proceed is# set to 'false' and the heavy build_and_enable job is skipped entirely.# Hardcoding 'dev' here would silently overwrite an active prod-us / prod-eu@@ -303,11 +303,11 @@ jobs:should_proceed: ${{ steps.pr_info.outputs.should_proceed }}steps:- # Charts deployer token for reading state.yaml on synchronize.- # state.yaml in PostHog/charts is the source of truth for the+ # Charts deployer token for reading state/feature-flags.yaml on synchronize.+ # state/feature-flags.yaml in PostHog/charts is the source of truth for the# active canary's target_environment; we read it here instead of# defaulting to 'dev' which would clobber a prod canary.- - name: Get charts deployer token (for state.yaml read)+ - name: Get charts deployer token (for state file read)id: charts_tokenif: github.event_name == 'pull_request' && github.event.action == 'synchronize'uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1@@ -323,7 +323,7 @@ jobs:env:GH_TOKEN: ${{ steps.charts_token.outputs.token }}run: |- # Synchronize-only: read PostHog/charts:state.yaml so the+ # Synchronize-only: read PostHog/charts:state/feature-flags.yaml so the# rebuild dispatch keeps the active canary in its current# environment. We MUST NOT silently default to `dev` on# network/auth/parse failure — that is the bug being fixed.@@ -331,7 +331,7 @@ jobs:tmp=$(mktemp)gh api \-H 'Accept: application/vnd.github.raw' \- repos/PostHog/charts/contents/state.yaml > "$tmp"+ repos/PostHog/charts/contents/state/feature-flags.yaml > "$tmp"enabled=$(yq '.state["feature-flags"].canary.enabled // false' "$tmp")active_pr=$(yq '.state["feature-flags"].canary.pr_number // 0' "$tmp")target_env=$(yq '.state["feature-flags"].canary.target_environment // ""' "$tmp")@@ -374,7 +374,7 @@ jobs:} else {// pull_request: synchronize.// The active canary's settings are the source of truth —- // read them from state.yaml (loaded by the state_lookup+ // read them from the charts state file (loaded by the state_lookup// step). If the canary is disabled or owned by a different// PR, skip the rebuild entirely; the user must use// /pr-canary to opt back in. Silently defaulting to@@ -403,7 +403,7 @@ jobs:if (!stateEnv) {core.setFailed(`Active canary for PR #${prNumber} has empty target_environment ` +- `in PostHog/charts:state.yaml — refusing to dispatch.`+ `in PostHog/charts:state/feature-flags.yaml — refusing to dispatch.`);return;}@@ -653,9 +653,9 @@ jobs:echo "Validated: weight=${CANARY_WEIGHT}, environment=${TARGET_ENVIRONMENT}"# Mirror of build_and_enable's failure reporter so that a preflight- # failure (team membership rejection, state.yaml fetch error, etc.)+ # failure (team membership rejection, state file fetch error, etc.)# leaves a comment on the PR. Fires for both /pr-canary comments- # and pull_request: synchronize events: on synchronize, a state.yaml+ # and pull_request: synchronize events: on synchronize, a state file# read failure would otherwise produce a red Action with no PR# signal.- name: Report failure on PR