{"record":{"id":"cb4255d04a6019fd","repo":"ZhuLinsen/daily_stock_analysis","slug":"00-daily-analysis-yml-is-missing-required-notifica","errorCode":null,"errorMessage":"00-daily-analysis.yml is missing required notification env mappings: {missing}","messagePattern":"00-daily-analysis\\.yml is missing required notification env mappings: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/generate_notification_actions_env_table.py","lineNumber":194,"sourceCode":"    if start == -1 or end == -1 or end < start:\n        raise ValueError(\n            f\"Could not find managed table markers {TABLE_START!r} and {TABLE_END!r}\"\n        )\n    before = markdown[: start + len(TABLE_START)]\n    after = markdown[end:]\n    return f\"{before}\\n\\n{table}\\n\\n{after.lstrip()}\"\n\n\ndef validate_required_mappings(env: dict[str, str]) -> None:\n    required = (\n        set(P0_ACTIONS_ENV_KEYS)\n        | set(P3_ROUTE_ENV_KEYS)\n        | set(P4_NOISE_ACTIONS_ENV_KEYS)\n        | set(P6_CHANNEL_ACTIONS_ENV_KEYS)\n    )\n    missing = sorted(required - set(env))\n    if missing:\n        raise ValueError(\n            \"00-daily-analysis.yml is missing required notification env mappings: \"\n            + \", \".join(missing)\n        )\n\n\ndef generate_table() -> str:\n    env = load_daily_analysis_env()\n    validate_required_mappings(env)\n    return render_markdown_table(build_notification_actions_env_rows(env))\n\n\ndef main(argv: list[str] | None = None) -> int:\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\"--write\", action=\"store_true\", help=\"Update docs/notifications.md in place\")\n    parser.add_argument(\"--check\", action=\"store_true\", help=\"Fail if docs/notifications.md is stale\")\n    args = parser.parse_args(argv)\n\n    table = generate_table()","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/scripts/generate_notification_actions_env_table.py#L176-L212","documentation":"validate_required_mappings diffs the env block of the '执行股票分析' workflow step against the union of P0/P3/P4/P6 notification env key sets. Any required key absent from the workflow's env raises ValueError listing the missing names. This keeps the generated notification env table and the actual CI configuration in lockstep.","triggerScenarios":"A PR removes or renames a notification-related env var (e.g. a P0_ACTIONS_ENV_KEYS entry like a channel/route variable) from the workflow step's env block; new keys added to the P*_ENV_KEYS constants in the script without adding them to the workflow; YAML typo in an env var name.","commonSituations":"Refactoring notification config: someone cleans 'unused' env vars out of 00-daily-analysis.yml not knowing the docs generator requires them; renaming env keys across the repo but missing the workflow; adding a new notification channel constant in the script first.","solutions":["Add each missing key from the error message to the env block of the '执行股票分析' step in .github/workflows/00-daily-analysis.yml with its proper ${{ secrets.VAR }} / default value.","If a key was intentionally retired, remove it from the corresponding P0/P3/P4/P6 constant in scripts/generate_notification_actions_env_table.py in the same change.","Re-run the generator and verify the docs table reflects the corrected mapping."],"exampleFix":"# before (workflow step env)\nenv:\n  NOTIFICATION_ACTIONS_ENABLED: 'true'\n  # NOTIFICATION_DEFAULT_ROUTE removed\n\n# after\nenv:\n  NOTIFICATION_ACTIONS_ENABLED: 'true'\n  NOTIFICATION_DEFAULT_ROUTE: ${{ secrets.NOTIFICATION_DEFAULT_ROUTE }}","handlingStrategy":"validation","validationCode":"from scripts.generate_notification_actions_env_table import (\n    P0_ACTIONS_ENV_KEYS, P3_ROUTE_ENV_KEYS, P4_NOISE_ACTIONS_ENV_KEYS,\n    P6_CHANNEL_ACTIONS_ENV_KEYS, load_daily_analysis_env,\n)\nenv = load_daily_analysis_env()\nmissing = (set(P0_ACTIONS_ENV_KEYS) | set(P3_ROUTE_ENV_KEYS)\n           | set(P4_NOISE_ACTIONS_ENV_KEYS) | set(P6_CHANNEL_ACTIONS_ENV_KEYS)) - set(env)\nassert not missing, f\"workflow env missing: {sorted(missing)}\"","typeGuard":null,"tryCatchPattern":"try:\n    generate_table()\nexcept ValueError as e:\n    if \"missing required notification env mappings\" in str(e):\n        add_missing_env_to_workflow(parse_names(str(e)))  # fix workflow, not the script\n    else:\n        raise","preventionTips":["Any env-key rename must update workflow + P*_ENV_KEYS constants + docs in one PR.","Run the generator in CI to catch workflow/docs drift at PR time.","Never prune workflow env vars as 'unused' without grepping the generator's required sets."],"tags":["ci","workflow","env","docs-generation"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}