Skip to content

fix: write .env.local for phpdotenv + skip API upload when no results.json#7

Merged
PrestaEdit merged 1 commit into
mainfrom
fix/dotenv-and-skip-upload-on-empty
Jul 12, 2026
Merged

fix: write .env.local for phpdotenv + skip API upload when no results.json#7
PrestaEdit merged 1 commit into
mainfrom
fix/dotenv-and-skip-upload-on-empty

Conversation

@PrestaEdit

Copy link
Copy Markdown
Contributor

Two related fixes

1. .env.local for phpdotenv

Even after v2.0.2 exported PRESTAFLOW_PS_VERSION, the lib still crashed with Class "…Pages\\v8\\Front\\GuestTracking\\Page" not found because the library reads via $_ENV['...'], which PHP only populates when variables_order includes Erarely the case in CI. The library relies on phpdotenv (Dotenv::createImmutable) to load .env / .env.local into $_ENV. Without either file, the process env vars are silently ignored.

Fix: when Flashlight is on, write .env.local at the workspace root with PRESTAFLOW_FO_URL + PRESTAFLOW_PS_VERSION. .env.local is loaded first by phpdotenv (immutable), so it wins over any existing .env.

2. Skip API upload when there's no results.json

Root cause of the recent Request failed with status code 453 on the smoke run: when composer crashes before producing results.json, we were still calling uploadToApi(), which rejected the empty payload with 453. The exception then bypassed the rest of the reporting flow, so outputs came out empty — losing the PR comment fix from #5 that would have shown the zero-state gracefully.

Fix: only call uploadToApi() when findResultsJson() returns a path. And even then, wrap the call so a residual error becomes a core.warning, not a hard failure. Artifacts + outputs + PR comment still run.

Reproduced from

Test plan

  • 43 unit tests pass, bundle rebuilt.
  • Re-run smoke on prestaflow-prestashop#2 after merge — expect v9 Page resolution and non-empty outputs.

🤖 Generated with Claude Code

….json

Root cause of 'Class Pages\v8\... not found' despite exporting
PRESTAFLOW_PS_VERSION: the library reads via $_ENV['...'], which PHP
only populates when variables_order includes 'E' — rarely the case in
CI. The library relies on phpdotenv (Dotenv::createImmutable) to load
.env / .env.local into $_ENV. Without one of those files, the process
env vars are ignored.

Fix: when Flashlight is on, write .env.local at the workspace root
with PRESTAFLOW_FO_URL + PRESTAFLOW_PS_VERSION. Loaded first by
phpdotenv (immutable), so it wins over any existing .env.

Also: when no results.json was produced (composer crash), skip the API
upload entirely and catch any residual error as a warning. The prior
behaviour tried to upload an empty payload, got a 453 back, threw, and
lost all subsequent reporting including the PR comment (which had
otherwise been fixed to show the zero-state gracefully).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@PrestaEdit
PrestaEdit merged commit 11cf026 into main Jul 12, 2026
1 check passed
@PrestaEdit
PrestaEdit deleted the fix/dotenv-and-skip-upload-on-empty branch July 12, 2026 07:27
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.

1 participant