ZhuLinsen/daily_stock_analysis · error · ValueError

Could not find managed table markers {TABLE_START!r} and {TA

Error message

Could not find managed table markers {TABLE_START!r} and {TABLE_END!r}

What it means

extract_managed_block scans a markdown doc for the managed-region markers '<!-- notification-actions-env-table:start -->' (TABLE_START) and its end counterpart; if either is missing or the end marker appears before the start marker, it raises. The markers delimit the auto-generated env table inside the notification docs so regeneration can replace only that block.

Source

Thrown at scripts/generate_notification_actions_env_table.py:166

                    _markdown_cell(channels),
                    _markdown_cell(row.source),
                    _markdown_cell(row.default),
                )
            )
            + " |"
        )
    return "\n".join(lines)


def normalize_markdown_block(content: str) -> str:
    return "\n".join(line.rstrip() for line in content.strip().splitlines())


def extract_managed_block(markdown: str) -> str:
    start = markdown.find(TABLE_START)
    end = markdown.find(TABLE_END)
    if start == -1 or end == -1 or end < start:
        raise ValueError(
            f"Could not find managed table markers {TABLE_START!r} and {TABLE_END!r}"
        )
    table_start = start + len(TABLE_START)
    return markdown[table_start:end].strip()


def replace_managed_block(markdown: str, table: str) -> str:
    start = markdown.find(TABLE_START)
    end = markdown.find(TABLE_END)
    if start == -1 or end == -1 or end < start:
        raise ValueError(
            f"Could not find managed table markers {TABLE_START!r} and {TABLE_END!r}"
        )
    before = markdown[: start + len(TABLE_START)]
    after = markdown[end:]
    return f"{before}\n\n{table}\n\n{after.lstrip()}"

View on GitHub (pinned to 5159bd72e8)

Solutions

  1. Restore both markers in the target doc, exactly as defined in scripts/generate_notification_actions_env_table.py:30-32 (start and end comments on their own lines).
  2. Keep any hand-written content outside the markers — everything between them is overwritten by generation.
  3. After restoring, run the script to verify extraction and regeneration succeed.
  4. If the doc was intentionally restructured, move the markers to the new location instead of deleting them.

Example fix

# before (docs/...md)
## Actions 环境变量
| key | ... |   <!-- markers deleted by hand -->

# after
## Actions 环境变量
<!-- notification-actions-env-table:start -->
<!-- notification-actions-env-table:end -->
Defensive patterns

Strategy: validation

Validate before calling

from scripts.generate_notification_actions_env_table import TABLE_START, TABLE_END

md = Path(doc_path).read_text()
assert TABLE_START in md and TABLE_END in md and md.index(TABLE_END) > md.index(TABLE_START), "managed markers missing/out of order"

Type guard

def has_managed_block(markdown: str) -> bool:
    s, e = markdown.find(TABLE_START), markdown.find(TABLE_END)
    return s != -1 and e != -1 and e > s

Prevention

When it happens

Trigger: The target markdown doc lost its marker comments — manual editing removed them, a formatter stripped HTML comments, the doc was rewritten from an old template, or the end marker was accidentally deleted leaving an unterminated block.

Common situations: Someone edits docs/*.md by hand and deletes the invisible HTML comments; a markdown formatter/linter purges comments; docs file replaced during a merge conflict resolution.

Related errors


AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15). Data as JSON: /api/errors/0fbe3d37cba16d25. Report an issue: GitHub.