ZhuLinsen/daily_stock_analysis · error · ValueError
Expected 00-daily-analysis.yml job analyze to include a step
Error message
Expected 00-daily-analysis.yml job analyze to include a step named {ANALYZE_STEP_NAME!r}; available step names: {available_step_names} What it means
scripts/generate_notification_actions_env_table.py parses .github/workflows/00-daily-analysis.yml, navigates jobs.analyze.steps, and requires exactly one step named '执行股票分析' (ANALYZE_STEP_NAME) to read its env block for the docs table. If the workflow has no step with that name, it raises ValueError listing the step names it did find — a consistency check between CI workflow and generated documentation.
Source
Thrown at scripts/generate_notification_actions_env_table.py:52
@dataclass(frozen=True)
class EnvTableRow:
key: str
tier: str
channels: tuple[str, ...]
source: str
default: str
def load_daily_analysis_env(workflow_path: Path = WORKFLOW_PATH) -> dict[str, str]:
"""Load the env block from the daily analysis workflow."""
workflow = yaml.safe_load(workflow_path.read_text(encoding="utf-8"))
steps = workflow["jobs"]["analyze"]["steps"]
analyze_step = next((step for step in steps if step.get("name") == ANALYZE_STEP_NAME), None)
available_step_names = [step.get("name", "<unnamed>") for step in steps]
if analyze_step is None:
raise ValueError(
f"Expected 00-daily-analysis.yml job analyze to include a step named "
f"{ANALYZE_STEP_NAME!r}; available step names: {available_step_names}"
)
return analyze_step["env"]
def _ordered_unique(values: Iterable[str]) -> tuple[str, ...]:
seen: set[str] = set()
ordered: list[str] = []
for value in values:
if value in seen:
continue
seen.add(value)
ordered.append(value)
return tuple(ordered)
def _key_metadata() -> dict[str, tuple[str, tuple[str, ...]]]:View on GitHub (pinned to 5159bd72e8)
Solutions
- Open .github/workflows/00-daily-analysis.yml, find jobs.analyze.steps, and restore/assign the step name '执行股票分析' on the step that carries the analysis env block.
- If the rename was intentional, update ANALYZE_STEP_NAME in scripts/generate_notification_actions_env_table.py:32 to the new name in the same PR.
- Confirm the job is still keyed 'analyze' — a job rename breaks workflow['jobs']['analyze'] with a different (KeyError) failure that should be fixed alongside.
- Re-run the script to confirm it now extracts the env block.
Example fix
# before (.github/workflows/00-daily-analysis.yml) - name: Run Analysis # renamed step env: ... # after - name: 执行股票分析 # must match ANALYZE_STEP_NAME env: ...
Defensive patterns
Strategy: validation
Validate before calling
import yaml
from pathlib import Path
wf = yaml.safe_load(Path(".github/workflows/00-daily-analysis.yml").read_text())
steps = wf["jobs"]["analyze"]["steps"]
names = [s.get("name") for s in steps]
assert "执行股票分析" in names, f"analyze step missing; got {names}" Try / catch
try:
env = load_daily_analysis_env()
except ValueError as e:
# CI/docs pipeline failure: fix workflow or ANALYZE_STEP_NAME, do not skip
raise SystemExit(f"workflow/docs drift: {e}") Prevention
- When renaming workflow steps, grep scripts/ for the literal step name first.
- Keep ANALYZE_STEP_NAME and the workflow step name in the same PR.
- Run the doc generator in CI so drift is caught at PR time, not release time.
When it happens
Trigger: Renaming the analyze step in 00-daily-analysis.yml; splitting it into multiple steps; reordering jobs so the analyze job id changes; YAML restructuring (steps moved to a composite action). Any of these without updating ANALYZE_STEP_NAME breaks the script.
Common situations: A PR edits the daily-analysis workflow (step rename, added checkout steps with names) and CI/docs generation then fails; local doc regeneration after pulling a workflow change; the 'available step names' list in the message shows what the script saw — compare it against the constant.
Related errors
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/52f446daa0a119fa.
Report an issue: GitHub.