Skip to content

Improve .python-version and runtime.txt error handling#1958

Merged
edmorley merged 1 commit into
mainfrom
python-version-file-encoding
Nov 12, 2025
Merged

Improve .python-version and runtime.txt error handling#1958
edmorley merged 1 commit into
mainfrom
python-version-file-encoding

Conversation

@edmorley
Copy link
Copy Markdown
Member

  • Improves the error message shown when a .python-version file uses an unsupported file encoding.
  • Improves the error message shown when a .python-version or runtime.txt file contain an invalid Python version.
  • Adds support for commented lines in runtime.txt, for parity with .python-version.
  • Adjust the metrics so now the raw (unescaped) invalid strings are recorded, for easier debugging.

GUS-W-19246790.
GUS-W-19280955.

@edmorley edmorley self-assigned this Nov 12, 2025
- Improves the error message shown when a `.python-version` file uses
  an unsupported file encoding.
- Improves the error message shown when a `.python-version` or
  `runtime.txt` file contain an invalid Python version.
- Adds support for commented lines in `runtime.txt`, for parity with
  `.python-version`.
- Adjust the metrics so now the raw (unescaped) invalid strings are
  recorded, for easier debugging.

GUS-W-19246790.
GUS-W-19280955.
@edmorley edmorley force-pushed the python-version-file-encoding branch from 288b8b6 to a11743f Compare November 12, 2025 15:24
@edmorley edmorley marked this pull request as ready for review November 12, 2025 15:29
@edmorley edmorley requested a review from a team as a code owner November 12, 2025 15:29
@edmorley edmorley merged commit cde4b67 into main Nov 12, 2025
6 checks passed
@edmorley edmorley deleted the python-version-file-encoding branch November 12, 2025 17:26
@heroku-linguist heroku-linguist Bot mentioned this pull request Nov 12, 2025
edmorley added a commit that referenced this pull request Nov 14, 2025
Some further improvements on-top of those made in #1958, based on build
error message scenarios seen in Honeycomb.

Now, if `.python-version` contains a single ESC control code (which gets
categorised as "very short file"), or contains any of the ASCI control
codes that result in the file being categorised as "data" (such as NUL),
then the "invalid python version" error message variant is shown instead
of the "invalid text encoding" variant.

In addition, any NULs in the file are substituted with a placeholder to
avoid this Bash warning:

```
/tmp/buildpack/lib/python_version.sh: line 104: warning: command substitution: ignored null byte in input
```

See:
https://manpages.ubuntu.com/manpages/noble/en/man1/file.1.html

GUS-W-20220514.
edmorley added a commit that referenced this pull request Nov 14, 2025
Some further improvements on-top of those made in #1958, based on build
error message scenarios seen in Honeycomb.

Now, if `.python-version` contains a single ESC control code (which gets
categorised as "very short file"), or contains any of the ASCI control
codes that result in the file being categorised as "data" (such as NUL),
then the "invalid python version" error message variant is shown instead
of the "invalid text encoding" variant.

In addition, any NULs in the file are substituted with a placeholder to
avoid this Bash warning:

```
/tmp/buildpack/lib/python_version.sh: line 104: warning: command substitution: ignored null byte in input
```

See:
https://manpages.ubuntu.com/manpages/noble/en/man1/file.1.html

GUS-W-20220514.
edmorley added a commit that referenced this pull request Nov 14, 2025
…1962)

Some further improvements on-top of those made in #1958, based on build
error message scenarios seen in Honeycomb.

Now, if `.python-version` contains a single ESC control code (which gets
categorised as "very short file"), or contains any of the ASCI control
codes that result in the file being categorised as "data" (such as NUL),
then the "invalid python version" error message variant is shown instead
of the "invalid text encoding" variant.

In addition, any NULs in the file are substituted with a placeholder to
avoid this Bash warning:

```
/tmp/buildpack/lib/python_version.sh: line 104: warning: command substitution: ignored null byte in input
```

See:
https://manpages.ubuntu.com/manpages/noble/en/man1/file.1.html

GUS-W-20220514.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants