Automattic / Automattic/wp-codebox

editor action unit suite crashes when RuntimeCreateSpec lacks environment

Open Beginner friendly
#2,105 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16
Forks
4
Avg merge
59m
Merged PRs (30d)
131

Description

## Problem

`npm run test:editor-actions` currently crashes before completing because a test fixture passes a `RuntimeCreateSpec` without `environment`, while `secretEnvPhp()` dereferences `spec.environment.databaseSetup` unconditionally.

## Failure

```text
TypeError: Cannot read properties of undefined (reading 'databaseSetup')
at secretEnvPhp (.../packages/runtime-playground/src/php-bootstrap.ts:280:24)
at bootstrapPhpCode (.../packages/runtime-playground/src/php-bootstrap.ts:41:3)
at resolveEditorOpenTarget (.../packages/runtime-playground/src/editor-actions.ts:140:11)
at .../tests/editor-actions.test.ts:288:24
```

## Expected

The test fixture should supply a valid runtime environment, or the bootstrap contract should reject/normalize the incomplete spec before dereferencing it. The editor action suite should run to completion on current `main`.

Discovered while validating the post-merge security hardening for #2094; the affected bootstrap and test fixture are outside that PR's changes.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with tests/editor-actions.test.ts around line 288, then inspect resolveEditorOpenTarget in packages/runtime-playground/src/editor-actions.ts and secretEnvPhp in packages/runtime-playground/src/php-bootstrap.ts. Run npm run test:editor-actions to reproduce the crash. Done means the suite completes successfully with a valid handling path for a RuntimeCreateSpec without environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.