Skip to content

pj_obj_create() regression: grid_alternatives not resolved in PROJ 9.8.0 #4698

@phaarnes

Description

@phaarnes

Transformer.from_pipeline("AUTH:CODE") fails for any grid-based
transformation whose registered grid filename (e.g. href2008a.bin) does
not exist on disk, even when a CDN alternative (e.g. no_kv_href2008a.tif)
is present and listed in the grid_alternatives table.

This worked correctly in PROJ 9.7.1. This was probably introduced in
commit 63c491eda3
("pj_obj_create(): do not open database", 2025-11-24), which was a
introduced to avoid the need for the database to apply a pipeline transformation. Database was mandatory in 9.7.1.

9.7.1 (line ~207):

auto dbContext = getDBcontextNoException(ctx, __FUNCTION__);
auto formatter = PROJStringFormatter::create(
    PROJStringFormatter::Convention::PROJ_5,
    std::move(dbContext));

9.8.0 (same location):

auto formatter = PROJStringFormatter::create(
    PROJStringFormatter::Convention::PROJ_5, nullptr);

With nullptr, the formatter emits the literal legacy grid name into the
pipeline string. When the pipeline is then instantiated, it tries to open
e.g. href2008a.bin which doesn't exist — only the .tif CDN variant
is on disk — and fails with:

pyproj.exceptions.ProjError: Input is not a transformation.:
  (Internal Proj Error: pipeline: Pipeline: Bad step definition:
   inv (File not found or invalid))

Example of problem

import pyproj
from pyproj import Transformer
from pyproj.transformer import TransformerGroup

print(f"PROJ {pyproj.proj_version_str}")  # 9.8.0

# EPSG:9484 = "ETRS89-NOR to NN54 height (1)"
# grid_name in DB: href2008a.bin
# grid_alternatives CDN name: no_kv_href2008a.tif  (exists on disk)

# from_pipeline — fails in 9.8.0, worked in 9.7.1
try:
    t = Transformer.from_pipeline("EPSG:9484")
    print(f"OK: {t.definition}")
except Exception as e:
    print(f"FAILED: {e}")

# TransformerGroup — still works, resolves grid_alternatives
tg = TransformerGroup("EPSG:10874", "EPSG:5776")
t = tg.transformers[0]
print(f"OK: {t.definition}")

Problem description

Affected operations: Any grid_transformation where the original
grid_param_name value doesn't exist on disk but a CDN .tif alternative
does. Examples: EPSG:9484 (href2008a.bin), EPSG:9485
(HREF2018B_NN2000_EUREF89.bin)

Expected behaviour

from_pipeline("EPSG:9484") should resolve href2008a.bin
no_kv_href2008a.tif via the grid_alternatives table, exactly as it
did in PROJ 9.7.1.

Environment Information

  • PROJ version 9.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions