Skip to content

fix(builds): handle files without extension in artifact processing#12921

Open
Bahtya wants to merge 1 commit intoreadthedocs:mainfrom
Bahtya:fix/file-without-extension-rsplit
Open

fix(builds): handle files without extension in artifact processing#12921
Bahtya wants to merge 1 commit intoreadthedocs:mainfrom
Bahtya:fix/file-without-extension-rsplit

Conversation

@Bahtya
Copy link
Copy Markdown

@Bahtya Bahtya commented Apr 8, 2026

Problem

When a build output file has no filename extension, the build crashes with:

_, extension = filename.rsplit(".")
ValueError: not enough values to unpack (expected 2, got 1)

This happens because rsplit(".") returns only one element when there is no . in the filename.

Fix

Check for . in the filename before calling rsplit. If the file has no extension, log a warning and skip it instead of crashing the build.

Fixes #12917

When a build output file has no filename extension, rsplit(".") returns
only one element, causing a ValueError when trying to unpack into two
variables. This crashes the entire build.

Add a check for "." in the filename and skip files without extensions
with a warning log instead of crashing.

Fixes readthedocs#12917

Signed-off-by: bahtya <bahtyar153@qq.com>
@Bahtya Bahtya requested a review from a team as a code owner April 8, 2026 11:15
@Bahtya Bahtya requested a review from agjohnson April 8, 2026 11:15
Copy link
Copy Markdown
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @Bahtya!

There are a few things happening with the logic here past just the failed string operation but I think it's fine to address the original bug in isolation.

"Skipping artifact file without extension: %s",
filename,
)
continue
Copy link
Copy Markdown
Contributor

@agjohnson agjohnson Apr 8, 2026

Choose a reason for hiding this comment

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

It would probably be best to move away from string operations entirely. Pathlib already handles these filename operations -- ie:

Path(list_dir[0]).suffix

There isn't a strong case to skip the file, we just need to be careful about not throwing an exception parsing the file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be good to get this in today for deploy -- @Bahtya if you have time could you push up the proposed fix, otherwise we should probably just apply the fix to the PR and merge.

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.

Build: files without filename extensions cause build failures during syncing

3 participants