Skip to content

Conversation

RabbitAlbatross
Copy link

When the MkDocs configuration file is missing, the build currently fails with an "Unknown error" message. This change raises a clearer and more helpful BuildUserError if the mkdocs.yml file is not found, similar to how Sphinx errors are handled.

Closes #11937

@RabbitAlbatross RabbitAlbatross requested a review from a team as a code owner August 4, 2025 16:25
@RabbitAlbatross RabbitAlbatross requested a review from stsewd August 4, 2025 16:25
Comment on lines 104 to 108
if not os.path.exists(self.yaml_file):
raise BuildUserError(
f"MkDocs configuration file is missing — we could not find a 'mkdocs.yml' file at {self.yaml_file}. "
"Please make sure your repository includes one and try again."
)
Copy link
Member

Choose a reason for hiding this comment

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

We should follow the same approach we use for Sphinx. See an example at https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/doc_builder/backends/sphinx.py#L112-L113

Copy link
Author

Choose a reason for hiding this comment

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

fixed. sorry for being so late.

Sorry for being so late.
Copy link

read-the-docs-community bot commented Sep 25, 2025

Documentation build overview

📚 dev | 🛠️ Build #29892173 | 📁 Comparing f767c43 against latest (39e5c8c)


🔍 Preview build

Show files changed (1 files in total): 📝 1 modified | ➕ 0 added | ➖ 0 deleted
File Status
settings.html 📝 modified

Copy link

read-the-docs-community bot commented Sep 25, 2025

Documentation build overview

📚 docs | 🛠️ Build #29892174 | 📁 Comparing f767c43 against latest (39e5c8c)


🔍 Preview build

Show files changed (9 files in total): 📝 9 modified | ➕ 0 added | ➖ 0 deleted
File Status
build-customization.html 📝 modified
visual-diff.html 📝 modified
config-file/index.html 📝 modified
config-file/v2.html 📝 modified
guides/conda.html 📝 modified
guides/private-submodules.html 📝 modified
guides/pull-requests.html 📝 modified
intro/add-project.html 📝 modified
reference/git-integration.html 📝 modified

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

This is going in a good direction. We just need to create a specific message for MkDocs.

added MKDOCS_NOT_FOUND constant to ProjectConfigurationError
added MkDocs notification for missing mkdocs.yml
raise MKDOCS_NOT_FOUND when mkdocs.yml is missing
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

This is moving in the right direction! 💪🏼

I left some comments about how to follow the pattern we already have for Sphinx.

Comment on lines 50 to 51
if not os.path.exists(self.yaml_file):
raise ProjectConfigurationError(ProjectConfigurationError.MKDOCS_NOT_FOUND)
Copy link
Member

Choose a reason for hiding this comment

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

We don't need this here.

Comment on lines 106 to 109

if not os.path.exists(self.yaml_file):
raise ProjectConfigurationError(ProjectConfigurationError.NOT_FOUND)

Copy link
Member

Choose a reason for hiding this comment

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

Please, move this code to show_config following the same pattern we are using for Sphinx. Take a look at its code at https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/doc_builder/backends/sphinx.py#L110-L124

RabbitAlbatross and others added 8 commits September 30, 2025 19:25
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
Removed the unneeded block
All requested changes added
Small error in the import fix
typos and stuff sorry
tests: add missing mkdocs config files

Created required mkdocs.yml files in tests to fix failures caused
by new file validation in show_conf() method.
Fixing test failures by creating actual mkdocs.yml files in tests that mock MkDocs configurations. The new file existence validation in show_conf() requires these files to exist for builds to proceed.
@RabbitAlbatross
Copy link
Author

Ready for a review

fixing to adhere to pre-commit checks
Pre-commit adherence
precommit fixes
pre-commit adherence
pre-commit fixes
pre-commit fixes
@humitos
Copy link
Member

humitos commented Oct 13, 2025

I don't follow the new changes you've done. It touches a few files that we haven't discussed and I don't understand why. The PR was pretty close, so I went ahead and opened a new one with the missing changes at #12521

@RabbitAlbatross
Copy link
Author

I'm sorry. It wasn't passing the tests so I ended up getting carried away trying to fix it.

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: "Unknown" error when mkdocs.yml is not found

2 participants