Skip to content

fix(server): resolve /history 500 error by correcting importlib.resources usage#3418

Open
dlstadther wants to merge 2 commits intospotify:masterfrom
dlstadther:fix-issue-3415
Open

fix(server): resolve /history 500 error by correcting importlib.resources usage#3418
dlstadther wants to merge 2 commits intospotify:masterfrom
dlstadther:fix-issue-3415

Conversation

@dlstadther
Copy link
Copy Markdown
Collaborator

Description

Replaces the broken importlib.resources usage in BaseTaskHistoryHandler.get_template_path() with the simpler os.path approach already used for static_path in the same file.

The previous code had three problems introduced in fc62c36 when pkg_resources was removed:

  1. import importlib does not make importlib.resources available — it must be explicitly imported as a submodule
  2. files("templates") references a non-existent top-level package named "templates"; the correct anchor is "luigi"
  3. .name returns only the basename ("templates"), not the full filesystem path that Tornado requires

The fix uses os.path.join(os.path.dirname(__file__), "templates"), which is already the established pattern for static_path on the line immediately below and requires no new imports.

Motivation and Context

Fixes #3415 . Visiting /history on any luigi scheduler with record_task_history = True results 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).

…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>
@dlstadther dlstadther requested a review from a team as a code owner April 11, 2026 01:45
@dlstadther dlstadther mentioned this pull request Apr 12, 2026
@dlstadther
Copy link
Copy Markdown
Collaborator Author

@RRap0so , could you review? Feel free to tag some other folk who i should be raises requests to.

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.

Scheduler /history endpoint throws 500 Server Error

1 participant