Repository navigation
Fix crash when library import argument cannot be converted - #5816
Merged
pekkaklarck merged 1 commit intoOct 22, 2026
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The localized fix preserves existing error handling and includes regression coverage for conversion failures and continued execution.
0 open findings
What changed in this PR
Fixes #5815 by reporting library argument conversion failures as import errors instead of stopping execution.
Changes:
- Wraps argument-resolution exceptions in
DataError, preserving existingDataErrors. - Adds unit coverage for successful conversion,
ValueError, andOverflowError. - Adds acceptance coverage for conversion failure and continued execution.
| File | Description |
|---|---|
utest/running/test_testlibrary.py |
Tests argument conversion and error handling. |
src/robot/running/testlibraries.py |
Converts resolution failures into import errors. |
atest/testresources/testlibs/libswithargs.py |
Adds a typed library fixture. |
atest/testdata/test_libraries/library_import_failing.robot |
Adds an invalid typed import. |
atest/robot/test_libraries/library_import_failing.robot |
Checks the conversion error message. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5815.
ClassLibrary.from_classnow turns errors from resolving and converting library arguments into aDataError.DataErrors, for example about a wrong number of arguments, are re-raised as they are. The failing import is then reported like other failing library imports, and execution continues:The fix handles
Exception, not onlyValueError, because built-in converters can raise other exceptions as well. For example,timeout=1e20with atimedeltaargument raisesOverflowError, and with aValueError-only handler that still crashes the execution.The message keeps the exception name, like conversion errors in keyword calls and in variable file arguments. Because of that, the failure message of the
Import Librarykeyword does not change. Libdoc now prints the message without theBuilding library '...' failed:prefix. It already does the same with otherDataErrors, for example a wrong number of arguments.Tests:
test_libraries/library_import_failing.robot. Without the fix the run of the test data crashes, so the existingImporting library with same name as Python built-in moduletest fails as well.TestLibraryInit.test_argument_conversion. It covers a successful conversion, aValueErrorand anOverflowError.I ran the full unit and acceptance test suites with Python 3.13 on Linux. All 2442 unit tests pass. Of the 7143 acceptance tests, 7134 pass. The 9 failing ones are Screenshot library tests, and they fail the same way on unmodified master, because taking screenshots is not supported in my environment.
utest/running/test_testlibrary.pyalso passes on Python 3.9 through 3.15. The changed files pass ruff, black and isort with the project configuration.AI/tooling disclosure: This contribution was prepared with assistance from Claude Code. I reviewed the result manually, understand the changes, verified them locally, and confirm that I have the right to submit this contribution under the project license.