Skip to content

fix(error-tracking): hand off a missing .env loader instead of wiring one - #408

Merged
gewenyu99 merged 2 commits into
mainfrom
posthog/fix-1329-env-file-start
Sep 24, 2026
Merged

gewenyu99 merged 2 commits into
mainfrom
posthog/fix-1329-env-file-start

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

The error-tracking flow stops editing a Node app's start and dev scripts to load .env. When nothing loads it, the agent names the gap in its handoff, and the report opens with a > ⚠️ **Needs your attention** block listing every follow-up.

Closes PostHog/wizard#1329

What broke

init.md offered --env-file=.env on start as an equal choice to dotenv. .env is gitignored, so it's missing where the app is deployed, and Node exits at boot (node: .env: not found, exit 9). The report also promised "every production build now uploads" when the credentials or CI step was skipped.

What's new

  • init.md, configure.md. No loader wiring. A missing loader becomes a manual follow-up.
  • report.md. Opens with the warning block. No upload promise while credentials or CI are pending.
  • error-tracking-env-loading.test.js. Pins these rules.
Verification

Created with PostHog Desktop

init.md offered `--env-file=.env` on the `start` script as an equal
option to dotenv. `.env` is gitignored, so it is usually missing where the
app is deployed, and `node --env-file=.env` exits 9 before any app code
runs when it is. init.md and configure.md now prefer dotenv, allow
`--env-file-if-exists=.env` only on Node 22.9+, and never put a hard
`--env-file=.env` on `start`.

report.md also said "every production build now uploads" whenever the
build was wired, even when the credentials or wire-ci handoff was
skipped. It now has a third branch for that case.

A contract test pins all three rules.

Closes PostHog/wizard#1329

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci feature-flags
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci feature-flags/django
  • /wizard-ci feature-flags/next-js
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a wizard branch:

  • /wizard-ci all wizard:my-branch

Add wizard:<branch> to any command above to pin the wizard branch. It defaults to main.

Results will be posted here when complete.

… one

Every way to wire a loader into a plain Node app guesses where it runs: a
hard --env-file stops the app where .env is missing, --env-file-if-exists
needs Node 22.9, and inlining the variables commits the key. init.md and
configure.md now leave the scripts alone and name the gap in the handoff
as a manual follow-up.

report.md opens with a `> ⚠️ **Needs your attention**` block listing
every follow-up. The wizard reads that block back on exit.

Closes PostHog/wizard#1329

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@gewenyu99 gewenyu99 changed the title fix(error-tracking): keep the start script working without .env fix(error-tracking): hand off a missing .env loader instead of wiring one Sep 24, 2026
@gewenyu99
gewenyu99 marked this pull request as ready for review September 24, 2026 16:00
@gewenyu99
gewenyu99 requested a review from a team as a code owner September 24, 2026 16:00

@ablaszkiewicz ablaszkiewicz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀 (not sure if we really need this test but I'm ok with it)

@gewenyu99
gewenyu99 merged commit 63b95aa into main Sep 24, 2026
16 checks passed
@gewenyu99

Copy link
Copy Markdown
Collaborator Author

tested, seems to work alright

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.

error-tracking flow can make a Node app's start script exit when .env is missing, and the report says uploads are wired when CI wiring was skipped

2 participants