Skip to content

Treat undecodable git output as no answer when pinning the plugin - #178

Merged
Deicyde merged 1 commit into
mainfrom
fix/scaffold-non-utf8-git-output
Oct 7, 2026
Merged

Deicyde merged 1 commit into
mainfrom
fix/scaffold-non-utf8-git-output

Conversation

@Deicyde

@Deicyde Deicyde commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

A one-line fix in autoform_cli/scaffold.py, plus one test (+15/-1).

plugin_pin reads each remote's URL through _git, which decodes git's output as text but caught only OSError and SubprocessError. If a remote URL is not valid UTF-8 (for example a .git/config with url = https://example.test/\xff), the decode raises UnicodeDecodeError, and nothing on the way up handles it as a git answer:

  • autoform init prints a traceback, because _init catches only ScaffoldError.
  • autoform project new refuses with the generic "The generated project did not satisfy Autoform's project contracts." error, because autoform_cli/project/create.py:178 catches UnicodeError around the whole plan.

_git now also catches UnicodeError and returns None. Every caller already treats None as no answer, so _safe_remote_source skips such a remote in the same way it skips one with an unsafe URL. This matches the byte-level readers beside it: _select_remote_source and _remote_contains_ref already treat undecodable output as no answer.

test_plugin_pin_skips_a_remote_whose_url_is_not_utf8 gives a fork origin a non-UTF-8 URL next to the canonical upstream, and expects the upstream pin. On main it fails with the UnicodeDecodeError; on this branch it passes.

#75 edits both files, and #90 and #145 edit tests/test_scaffold.py. Each merges with this branch without adding a conflict. All three already conflict with main, so none of them can be test-merged with this branch yet.

Validation at exact head e93fd5e8: ruff check autoform_cli servers tests is clean. tests/test_scaffold.py (106) and tests/test_project_create.py (257) pass.

_git decodes git's output as text but caught only OSError and
SubprocessError, so a remote whose URL is not UTF-8 raised
UnicodeDecodeError out of plugin_pin. autoform init printed a
traceback, and autoform project new refused to create the project with
the generic "did not satisfy Autoform's project contracts" error.
_git now returns None, as it does for other unreadable answers, so the
remote is skipped like an unsafe one.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 7, 2026
@Deicyde
Deicyde marked this pull request as ready for review October 7, 2026 06:52
@Deicyde
Deicyde merged commit 4aa709c into main Oct 7, 2026
9 checks passed
@Deicyde
Deicyde deleted the fix/scaffold-non-utf8-git-output branch October 7, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant