8000 [bug] raising ConanInvalidConfiguration from pre_validate hook propagates exception · Issue #18384 · conan-io/conan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[bug] raising ConanInvalidConfiguration from pre_validate hook propagates exception #18384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jcar87 opened this issue May 29, 2025 · 0 comments · May be fixed by #18385
Open

[bug] raising ConanInvalidConfiguration from pre_validate hook propagates exception #18384

jcar87 opened this issue May 29, 2025 · 0 comments · May be fixed by #18385
Assignees
Milestone

Comments

@jcar87
Copy link
Contributor
jcar87 commented May 29, 2025

Describe the bug

With a hook like this:

def pre_validate(conanfile):
    if some_condition_external_to_the_recipe:
        raise ConanInvalidConfiguration("Raised from pre_validate")

The expectation is that this behaves as if exception was raised from within the validate() method.
Instead, the exception is propagated all the way to the top

The problem is here:

if hasattr(conanfile, "validate"):
with conanfile_exception_formatter(conanfile, "validate"):
if hook_manager:
hook_manager.execute("pre_validate", conanfile=conanfile)
with conanfile_remove_attr(conanfile, ['cpp_info'], "validate"):
try:
conanfile.validate()
except ConanInvalidConfiguration as e:
conanfile.info.invalid = str(e)
if hook_manager:
hook_manager.execute("post_validate", conanfile=conanfile)

The hooks should be invoked from within the try/except clause

How to reproduce it

No response

@jcar87 jcar87 added this to the 2.18.0 milestone May 29, 2025
@uilianries uilianries linked a pull request May 29, 2025 that will close this issue
5 tasks
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 a pull request may close this issue.

2 participants
0