fix(server): resolve /history 500 error by correcting importlib.resources usage#3418
Open
dlstadther wants to merge 2 commits intospotify:masterfrom
Open
fix(server): resolve /history 500 error by correcting importlib.resources usage#3418dlstadther wants to merge 2 commits intospotify:masterfrom
dlstadther wants to merge 2 commits intospotify:masterfrom
Conversation
…rces usage Fixes spotify#3415. Replace broken importlib.resources usage in BaseTaskHistoryHandler.get_template_path() with the os.path approach already used for static_path in the same file. The pkg_resources removal in fc62c36 introduced three bugs: - `import importlib` does not expose importlib.resources as a submodule - files("templates") references a non-existent top-level package - .name returns only the basename, not the full path tornado requires Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Open
Collaborator
Author
|
@RRap0so , could you review? Feel free to tag some other folk who i should be raises requests to. |
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.
Description
Replaces the broken
importlib.resourcesusage inBaseTaskHistoryHandler.get_template_path()with the simpleros.pathapproach already used forstatic_pathin the same file.The previous code had three problems introduced in fc62c36 when
pkg_resourceswas removed:import importlibdoes not makeimportlib.resourcesavailable — it must be explicitly imported as a submodulefiles("templates")references a non-existent top-level package named"templates"; the correct anchor is"luigi".namereturns only the basename ("templates"), not the full filesystem path that Tornado requiresThe fix uses
os.path.join(os.path.dirname(__file__), "templates"), which is already the established pattern forstatic_pathon the line immediately below and requires no new imports.Motivation and Context
Fixes #3415 . Visiting
/historyon any luigi scheduler withrecord_task_history = Trueresults in a 500 Internal Server Error on luigi 3.7.3+ due to the AttributeError described above. This affects all supported Python versions (3.10–3.13).Have you tested this? If so, how?
New test included.
I also manually reproduced the 500 error against a fresh Python 3.13 environment with luigi==3.8.0 and confirmed the fix resolves it (using the "Steps to reproduce" included in the linked Issue).