Skip to content

fix(tiles): pass server templates to render_j2_template for TMS endpoints - #2428

Open
C1-BA-B1-F3 wants to merge 2 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/tms-template-config
Open

C1-BA-B1-F3 wants to merge 2 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/tms-template-config

Conversation

@C1-BA-B1-F3

Copy link
Copy Markdown
Contributor

Summary

The tilematrixsets and tilematrixset HTML handlers passed api.tpl_config as the template configuration:

content = render_j2_template(api.tpl_config, api.tpl_config,
                             'tilematrixsets/index.html', ...)

But api.tpl_config is a deep copy of the full server config (it has server, metadata, etc.) and lacks the path key that render_j2_template expects. The try/except (KeyError, TypeError) in render_j2_template then silently fell back to the default templates, so any custom theme was ignored.

Every other call site passes api.config['server']['templates'] (which has the path key). This PR aligns the two TMS handlers to the same pattern.

Changes

  • pygeoapi/api/tiles.py: tilematrixsets() and tilematrixset() now pass api.config['server']['templates'] to render_j2_template

Test plan

  • Verified manually that custom themes under templates/tilematrixsets/ are now picked up (the issue reporter's hand-drawn theme).

Fixes #2422

PostgreSQL and MongoDB managers ignored the limit and offset
parameters, returning all jobs regardless of the query string.

Apply offset before limit in both backends, matching the existing
TinyDB behaviour.

Fixes geopython#2426
…ints

The tilematrixsets and tilematrixset HTML handlers passed api.tpl_config
as the template configuration, but that dict carries the full server
config (including 'server') and lacks the 'path' key that
render_j2_template expects. The lookup therefore always fell back to
the default templates, ignoring any custom theme.

Pass api.config['server']['templates'] instead, matching every other
render_j2_template call site.

Fixes geopython#2422
@C1-BA-B1-F3

Copy link
Copy Markdown
Contributor Author

The Build failure is in test_describe_collections (assert 9 == 10) and test_get_collection_edr_query (HTTP 500), both of which also fail on the current master branch (see the 2026-09-29 templating branch run). These are pre-existing upstream regressions unrelated to this TMS template change.

The two failing tests exercise /collections and EDR queries; this PR only touches pygeoapi/api/tiles.py (the tilematrixsets and tilematrixset handlers). No collection or EDR code is modified.

Happy to rebase once upstream fixes the CI environment.

This branch has not been deployed

No deployments
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.

Template broken for TMS endpoints

1 participant