Skip to content

fix: check tls, api, certs - #1501

Merged
edwinyjlim merged 6 commits into
mainfrom
fix-project-fetch-network
Oct 29, 2026
Merged

edwinyjlim merged 6 commits into
mainfrom
fix-project-fetch-network

Conversation

@edwinyjlim

@edwinyjlim edwinyjlim commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

When the wizard can't load the project or user after login, it now says why and who can fix it. Before, every such failure showed Failed to fetch project data.

What it checks

  • API calls. The project and user fetches retry twice (after 500 ms, then 1.5 s) on a network error, a 5xx, a 408 or a 429. A 401, 403 or 404 fails at once. The final error names the host and the cause: Node's error code (such as ECONNRESET) or the HTTP status.

  • Certificate. When Node rejects the server's certificate (SELF_SIGNED_CERT_IN_CHAIN, UNABLE_TO_GET_ISSUER_CERT_LOCALLY and similar), a VPN, proxy or security tool is likely intercepting HTTPS. These errors aren't retried. The message tells the user to ask IT to allow *.posthog.com without HTTPS inspection.

  • TLS connection. On a certificate error only, src/shared/tls-check.ts opens one connection to the same host. It does a verified TLS handshake against Node's defaults plus the OS store, sends nothing and closes. Certificate validation stays on. It records:

    • whether that handshake verifies (system_store_trusts, true or false), in the log and on the captured exception. True means a root installed on the machine, typically by IT, signed the chain;
    • when it verifies, the top issuer of the chain (for example, a security vendor's root instead of a public certificate authority), in the local log only, since it can name the user's company.

    Nothing changes what the wizard or the machine trusts, and the wizard suggests no workaround.

  • Local dev. For localhost, 127.0.0.1 and [::1], a server that doesn't answer fails at once with "Check that your local server is running". There's no retry, no TLS check and no network advice.

Log line on a certificate error:

[tls] us.posthog.com chain signed by "<issuer>"; trusted by the system store: true
[tls] us.posthog.com chain signed by "unknown"; trusted by the system store: false

What users see

These are frames from OutroScreen, rendered with each message. A login failure has no credentials yet, so it shows this screen rather than the handoff.

Untrusted certificate (TLS inspection)

wizard-error-tls

No response (blocked or dropped connection)

wizard-error-network

Unexpected status after retries

wizard-error-status

Local PostHog not running
wizard-error-local

Before this change, for every case above

wizard-error-before

Testing

  • Unit tests: src/shared/__tests__/api-errors.test.ts (retry policy, messages, TLS check gating, local hosts) and src/shared/__tests__/tls-check.test.ts (validation on, issuer walk, verified and failed chains, other handshake failures).
  • Live TLS check: us.posthog.com and eu.posthog.com report a public CA issuer with systemStoreTrusts: true. self-signed.badssl.com and untrusted-root.badssl.com report false.
  • Not yet run behind a real HTTPS-inspecting proxy (Zscaler, Cloudflare WARP).

🤖 Generated with Claude Code

@edwinyjlim
edwinyjlim requested a review from a team as a code owner October 29, 2026 20:00
@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 Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

Comment thread src/shared/tls-probe.ts Fixed
@edwinyjlim edwinyjlim changed the title check tls, api, certs fix: check tls, api, certs Oct 29, 2026

@sarahxsanders sarahxsanders left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

bot review — from sarah's agent review

  • src/shared/tls-probe.ts:67: can we probe through the same proxy axios used? otherwise this can report a trusted public chain while the actual request failed on the proxy's certificate.
  • src/shared/api.ts:521: can we pass the hostname and port separately? with --base-url https://example.com:8443, this tries to resolve example.com:8443 and connects on 443, so the probe never checks the failing endpoint.

@sarahxsanders sarahxsanders left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

my agent had thoughts as well

Comment thread src/shared/http-proxy.ts Outdated
@veria-ai

veria-ai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@edwinyjlim
edwinyjlim merged commit d123906 into main Oct 29, 2026
18 checks passed
@edwinyjlim
edwinyjlim deleted the fix-project-fetch-network branch October 29, 2026 21:23
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