Skip to content

Commit 62f5c2c

Browse files
authored
fix: surface generate_ast.py failures with a clear error (#76)
## Summary `processPythonDocs` only checks `spawnSync().error`, which is set when the spawn itself fails — a non-zero exit of `generate_ast.py` (e.g. `pydoc-markdown` not importable by the resolved `python`) went completely unnoticed. The plugin then crashed later with a confusing `ENOENT: pydoc-markdown-dump.json`, hiding the real cause. This is exactly what made the broken `Version docs` CI job in apify/apify-sdk-python (failed 3.4.0/3.4.1 doc releases) hard to diagnose — see apify/apify-sdk-python#928 for the workflow-side fix. Now the exit code is checked and the script's stderr is included in the thrown error: ``` [ERROR] Error: The generate_ast.py script failed with exit code 1: ModuleNotFoundError: No module named pydoc_markdown ``` Verified by building the plugin, dropping the compiled output into the SDK website's `node_modules`, and running `docusaurus api:version` with a stub `python` that exits 1.
1 parent 8ba5cfe commit 62f5c2c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/plugin/python/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ export function processPythonDocs({
3131
]);
3232

3333
if (out.error) {
34-
throw new Error(out.error.message);
34+
throw new Error(`Failed to spawn the generate_ast.py script: ${out.error.message}`);
35+
}
36+
37+
if (out.status !== 0) {
38+
throw new Error(
39+
`The generate_ast.py script failed with exit code ${out.status}:\n${out.stderr.toString()}`,
40+
);
3541
}
3642

3743
const moduleShortcuts = JSON.parse(fs.readFileSync(moduleShortcutsPath, 'utf8')) as Record<

0 commit comments

Comments
 (0)