Skip to content

fix(docs): the error catalog lists the onboard errors - #6829

Merged
dan-petty merged 9 commits into
mainfrom
fix/6815-error-catalog-onboard-errors
Nov 23, 2026
Merged

dan-petty merged 9 commits into
mainfrom
fix/6815-error-catalog-onboard-errors

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The error catalog docs/ERRORS.md did not list the four errors of devops repos onboard (#6806). The generator imported only the modules of devops_cli.exceptions and of CONST_DOMAIN_EXCEPTION_MODULES, a hand list. No check failed, and the catalog test passed or failed with the shard layout. #6810 added the two modules to the list, but the next module can miss it again.

The generator now imports the module of each .py file of the package, so __subclasses__ gives every error class that a module defines. The hand list goes. The generator does not use pkgutil.walk_packages, because it skips devops_cli/docker/, a directory with no __init__.py. DocGenerator.catalog_module_names gives the names. A new test runs the import step and expects the module of each file to be loaded.

devops docs generate and the catalog tests each take about 2 s more. The generated docs do not change.

Closes #6815

Change: openspec/changes/archive/2026-11-23-6815-error-catalog-onboard-errors/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/docs Documents, guides, ADRs and generated references labels Nov 23, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Review of #6815: the error catalog lists the onboard errors

Recommendation

open-and-ready. No finding above nit stands. Head: 4305b7800.

Rebase on origin/main before the push. The branch is 4 commits behind origin/main (54a36e99a). A trial merge (git merge-tree) has no conflict. The commits on main add no error class, so docs/ERRORS.md stays the same after the rebase. Run the scoped tests again after the rebase.

Lenses and checks

Five lenses ran: fidelity (ok), tests (ok), correctness (ok), standards (concerns) and adversarial (concerns). Two fix rounds removed each concern. A recheck confirmed each fix.

  • devops ci --check rows lint, format, docs, constructs, openspec, test-settings, test-tree, startup-imports and swallowed-failures: all pass.
  • pytest -n 4 tests/docs tests/github/onboard/test_onboard_routes.py: 160 passed.
  • The catalog row test alone and after test_onboard_routes.py in one process: pass (36 passed).
  • DocGenerator.generate_error_catalog_docs() gives docs/ERRORS.md byte for byte.
  • openspec validate --all --strict: 425 passed. vale on the OpenSpec files and on the PR body: 0 alerts.
  • ruff check, ruff format and mypy on the changed source files: clean.
  • State-leak runs with the full import first in one process: 2711 and 1238 tests, no new failure.

Fail-to-pass

1 test fails on the base and passes on the head: tests/docs/test_exceptions.py::test_the_error_catalog_imports_the_module_of_each_source_file. The base has no catalog_module_names. The other 12 tests of the module pass on the base and on the head.

Standing findings (all nit)

  1. Old name and error text.
    • Where: src/devops_cli/docs/generator.py:889 and :898.
    • Problem: the name _import_all_exception_modules and the text "Failed to import exception module" are not true now. The step imports each module, and most modules define no error class.
    • Evidence: a forced import failure printed "Failed to import exception module 'devops_cli.docker.cosign'". That module defines no error class.
    • Fix: write "Failed to import module '{mod_name}' for the error catalog". Optionally rename the method and change the call at tests/docs/test_exceptions.py:146.
  2. The guard test does not see the import loop.
    • Where: tests/docs/test_exceptions.py:157-170.
    • Problem: the test checks only catalog_module_names. A hand list in the import loop can come back, and this test still passes. The test also finds only .py files, as the product code does.
    • Evidence: the test body is one set comparison. On the base, it fails only with an AttributeError.
    • Fix: accept it as the trade-off of design decision 4. Or let the loop take the names as a parameter, so that a test can give names and see them imported.
  3. Runtime discovery has limits.
    • Where: src/devops_cli/docs/generator.py:874-899.
    • Problem: the catalog cannot see three kinds of class. They are a class in a function body, a class in the else of an optional import, and a class from a module __getattr__.
    • Evidence: a scratch tree with these classes left them out, and the guard passed. An AST scan of the real source finds no such class today.
    • Fix: optional. Add one sentence to the docstring or the spec: the catalog lists the classes that a module defines at import time.
  4. The import step changes process state.
    • Where: src/devops_cli/docs/generator.py:893.
    • Problem: the step loads about 3500 more modules into the process or the pytest worker.
    • Evidence: atexit callbacks went from 2 to 9, warning filters from 5 to 17, and one finder went into sys.meta_path. No test failed in the state-leak runs.
    • Fix: none now. If a test-order failure occurs, look at this step first.
  5. The cost is higher on a loaded host.
    • Where: devops docs generate.
    • Problem: the PR body gives about 2 s more. That is the idle number.
    • Evidence: idle median 5.95 s before and 8.24 s after. At a load of 14 on 16 CPUs: 10.20 s before and 15.06 s after.
    • Fix: none needed. The docs stage is not in a commit hook.
  6. The branch is behind main. See the recommendation.

Fixed findings

  • Standards (minor): a test comment sentence had 35 words. Fix round 1 removed the comment with the probe.
  • Standards (minor): the spec Purpose and the archived change had long sentences. Fix round 1 split them, and vale gives 0 alerts.
  • Standards (nit, part): the passive docstring "so it is not used" is now active.
  • Adversarial (minor): the fresh-interpreter probe took 10 to 15 s. Fix round 1 changed it to a name comparison that takes 0.04 s.
  • Tests (nit): the duration record did not show the probe cost. The probe is gone.
  • Recheck (minor): the test module takes about 2 s in a fresh worker, and the record gives 0.2 s. Fix round 2 gives this cost in design decision 3.
  • PR body: the review corrected three claims. feat(roadmap): Add toolsets for implement and review #6810 added the two modules, not feat(roadmap): Add toolsets for implement and review from one registry #3244. The catalog did not list the errors before. The import finds each class that a module defines.

Design decisions

  • No hand list: the generator imports the module of each .py file (Path.rglob, import_graph.module_name, importlib). The list was the cause.
  • Not pkgutil.walk_packages: it skips devops_cli/docker/, which has 6 modules and no __init__.py.
  • Not a hand list with a guard test: the guard costs the same imports, and a person still edits the list.
  • Not an AST scan of class bases: it needs our own name resolution.
  • Not a move of all 21 error classes into devops_cli.exceptions: that is a separate refactor, and it does not stop a new module.
  • The guard test compares names and starts no process. It does not patch importlib, because the import system is not an edge.
  • tests/module_durations.json keeps 0.2 s: the file holds measured times. About 2 s is 0.3 % of a shard. The refresh from main writes the true value.
  • A failed import still stops the docs stage.
  • New capability docs-error-catalog: no base spec covered docs/ERRORS.md.

Not part of this change

  • tests/core/test_git_contract.py review_window: 2 tests fail on main and on the head. Open issue fix(tests): pass the review_window git contract with git 2.55 #6380 covers it.
  • docs/ERRORS.md: 16 rows stop in the middle of a sentence, because the generator uses only the first docstring line. One example is BaselineUnreadableError at line 36. No open issue covers it.
  • mypy on tests/docs/test_exceptions.py: 2 arg-type errors in _built were on the base before this change.

After the review

  • The coordinator rebased the branch onto the newest main with no conflict.
  • The message of a failed import now says "Failed to import module ... for the error catalog". This fixes the nit on the old text.
  • The guard test now runs the import step and expects the module of each .py file in sys.modules. Before, it compared catalog_module_names with a set built the same way, and it failed on the base only with an AttributeError. Now it fails on the base with an AssertionError that lists the modules that the old step did not load. The archived tasks, proposal and design say the same.
  • Checks after these changes: tests/docs and tests/github/onboard give 189 passed; the docs, lint, format, openspec and startup-imports rows pass; fail-to-pass gives 1 test that fails on the base.

@dan-petty
dan-petty marked this pull request as ready for review November 23, 2026 01:55
@dan-petty
dan-petty merged commit 1846b2d into main Nov 23, 2026
28 checks passed
@dan-petty
dan-petty deleted the fix/6815-error-catalog-onboard-errors branch November 23, 2026 01:56
dan-petty pushed a commit that referenced this pull request Nov 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.198.0](v0.197.0...v0.198.0)
(2026-11-23)


### Features

* **ci:** refuse changes to environment paths after the switch
([#6823](#6823))
([ad366bb](ad366bb))
* **roadmap:** Add requirement text to the stage context
([#6826](#6826))
([615bbc4](615bbc4))
* **roadmap:** Require a rejected alternative with a fact
([#6836](#6836))
([5467e22](5467e22))
* **roadmap:** The stage plan states constant claims
([#6837](#6837))
([5ea6d02](5ea6d02))


### Bug Fixes

* **deps:** update ghcr.io/dan-petty/devtools Docker tag to v1.1.1
([#6834](#6834))
([ea1b00f](ea1b00f))
* **docs:** the error catalog lists the onboard errors
([#6829](#6829))
([1846b2d](1846b2d))
* **roadmap:** name a spent provider key, not a refused key
([#6827](#6827))
([3aedb2f](3aedb2f))
* **roadmap:** read a record below a block a person opens
([#6812](#6812))
([54a36e9](54a36e9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/docs Documents, guides, ADRs and generated references type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(docs): the error catalog lists the onboard errors

1 participant