Skip to content

refactor: parse TOML once in deprecation detection and migration - #1876

Merged
max-sixty merged 2 commits into
mainfrom
deprecation-parse-once
Apr 1, 2026
Merged

max-sixty merged 2 commits into
mainfrom
deprecation-parse-once

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

detect_deprecations() parsed TOML 6 times (once per find_* function) and write_migration_file() parsed 6 more times (once per migrate_* function). Each function independently called content.parse::<toml_edit::DocumentMut>().

Now each entry point parses once and passes the document to internal _from_doc/_doc variants. String extraction for template variable detection also switched from toml::Table to toml_edit::DocumentMut, so the entire module uses one TOML parser. The former pub wrapper functions moved to the test module as helpers.

This was written by Claude Code on behalf of @max-sixty

detect_deprecations() was parsing TOML 6 times (once per find_* function) and
write_migration_file() was parsing 6 more times (once per migrate_* function).

Extract _from_doc/_doc internal variants that take the already-parsed
DocumentMut, so each entry point parses once. Also switch string extraction
from toml::Table to toml_edit::DocumentMut, eliminating the second parser.

Co-Authored-By: Claude <[email protected]>
worktrunk-bot
worktrunk-bot previously approved these changes Apr 1, 2026
@worktrunk-bot
worktrunk-bot dismissed their stale review April 1, 2026 18:30

codecov/patch failed — new uncovered lines in refactored code

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov/patch failed. The new code has a few uncovered branches:

  1. Lines 144–149 (collect_strings_from_edit_item): The ArrayOfTables branch and wildcard _ => {} — no test config uses [[array_of_tables]] syntax, so these are never exercised.

  2. Lines 992, 998 (write_migration_file): The "structural deprecations detected but none actually modified" and "TOML re-parse failure after var replacement" branches — both are defensive edge cases.

  3. Line 120 (extract_template_strings): The TOML parse-failure early return — pre-existing uncovered path, but the function body changed so codecov flags it.

The easiest fix would be a small test that calls extract_template_strings (or detect_deprecations) with content containing an array-of-tables with a string value, covering the ArrayOfTables branch. I can push a fix commit if you'd like.

Add test for deprecated var detection inside [[array_of_tables]] sections,
covering the ArrayOfTables branch in collect_strings_from_edit_item. Remove
the has_structural pre-check in write_migration_file — the individual
migrate functions already guard their conditions.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 96e07da into main Apr 1, 2026
22 checks passed
@max-sixty
max-sixty deleted the deprecation-parse-once branch April 1, 2026 18:43
max-sixty added a commit that referenced this pull request Apr 1, 2026
Follow-up to #1876. `check_and_migrate()` now parses the TOML content
once and threads the parsed document and template strings through to
both `detect_deprecations_from_doc()` and `write_migration_file()`,
eliminating the last redundant parse in the deprecation pipeline.

The `extract_template_strings` and `replace_deprecated_vars` convenience
wrappers (which parsed internally) are now test-only helpers. Production
code uses the `_from_strings`/`_from_doc` variants exclusively.

> _This was written by Claude Code on behalf of @max-sixty_

Co-authored-by: Claude <[email protected]>
max-sixty pushed a commit that referenced this pull request Jun 7, 2026
…2997)

## Problem

The non-required `code-coverage` job failed on `main` (run
[27075953927](https://github.com/max-sixty/worktrunk/actions/runs/27075953927)).
All tests passed (1942 / 1238 / 703, 0 failed); the failure was in the
`codecov/[email protected]` upload step:

```
==> Finishing downloading linux:latest
      Version: v11.2.8
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
==> Verifying GPG signature integrity
gpg: Signature made Tue Apr 21 19:28:03 2026 UTC
gpg:                using RSA key 27034E7FDB850E0BBC2C62FF806BB28AED779869
gpg: Can't check signature: No public key
==> Could not verify signature. Please contact Codecov if problem continues
    Exiting...
##[error]Process completed with exit code 1.
```

**Root cause (confirmed upstream).** The action downloads the Codecov
CLI from `cli.codecov.io` and verifies its GPG signature against a
public key fetched from
`https://keybase.io/codecovsecurity/pgp_keys.asc`. That URL is currently
returning `404 SELF-SIGNED PUBLIC KEY NOT FOUND`, so the key import
produces "no valid OpenPGP data found", the keyring stays empty, and the
signature check aborts with "No public key" — before any upload happens.
Tracked in
[codecov/codecov-action#1955](codecov/codecov-action#1955)
(opened the same day) and the related
[#1876](codecov/codecov-action#1876).

**Why a fix and not a rerun.** This exact failure shape fired three
times in ~24h —
[#2993](#2993),
[#2996](#2996), and this
run. #2996's diagnosis explicitly flagged that a third occurrence should
escalate to a durable mitigation, crossing the `running-tend`
repeat-occurrence threshold from transient to durable. `v6.0.1` is
already the latest action release, so bumping the pin doesn't help.

## Solution

Set `use_pypi: true` on both `codecov-action` steps in `ci.yaml` (the
test-results upload in the `test` matrix and the coverage upload in
`code-coverage`). This is the workaround documented in #1955: it
installs the Codecov CLI from PyPI instead of `cli.codecov.io`,
bypassing the binary download and its broken Keybase GPG-key import
entirely. Both call sites are subject to the same failure mode, so both
are patched.

`use_pypi` is a documented input on `[email protected]`
(`action.yml` line 155: *"Use the pypi version of the CLI instead of
from cli.codecov.io"*).

## Testing

YAML validated with `yaml.safe_load`. Behavioral verification is the
`code-coverage` job passing on this PR — it exercises the patched upload
path. The maintainer can revert `use_pypi: true` once Codecov restores
the Keybase key (the `# (codecov/codecov-action#1955)` comments mark
both sites).

---
Automated fix for [failed
run](https://github.com/max-sixty/worktrunk/actions/runs/27075953927)

Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants