UGRID load loses the mesh when a connectivity variable lacks cf_role or start_index

Open Beginner friendly
#7,332 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Sulaiman-Dauda is already working on this.

Since Nov 2, 2026.

  • #7365 by @Sulaiman-Dauda — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
data

Research direction

Start in _build_connectivity in iris.fileformats.netcdf.ugrid_load, where cf_role and start_index are read directly from the connectivity variable. Reproduce by saving iris.tests.stock.mesh.sample_mesh_cube, removing start_index, and reloading. Done when a missing start_index falls back to 0 and the pinned test in lib/iris/tests/integration/test_cf.py is inverted. Decide how a missing cf_role should fail, with a message that names the attribute.

Written by the indexing model from the issue text.

Description

Type: Bug

(posted by Claude Opus)

iris.fileformats.netcdf.ugrid_load._build_connectivity reads cf_role and start_index straight off the connectivity variable, and a file missing either one loses its mesh: the mesh build raises, the failure lands in iris.loading.LOAD_PROBLEMS, and the user gets an IrisLoadWarning and a mesh-less cube.

Neither read is guarded, and nothing upstream guarantees either attribute. CFUGridConnectivityVariable.identify finds the connectivity variable through the mesh variable's role attribute — face_node_connectivity and friends — so it never looks at the connectivity variable's own cf_role.

start_index is the clearer bug of the two: CF-UGRID makes it optional with a default of 0, and iris.mesh.Connectivity already defaults it to 0, so the loader should fall back rather than raise. cf_role is required by UGRID, so raising is defensible, but the message a user gets does not say which attribute was missing.

Reproduced by saving iris.tests.stock.mesh.sample_mesh_cube, deleting start_index from the connectivity variables, and reloading.

Found while moving the last internal CF attribute reads off CFVariable.__getattr__. Not fixed there: that branch is behaviour-only apart from the deprecation it adds. The current behaviour is pinned by a test in lib/iris/tests/integration/test_cf.py, which will need inverting when this is fixed.

Dominant language
Python
Stars
730
Forks
322
Avg merge
1d 18h
Merged PRs (30d)
21

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SciTools/iris

All issues in SciTools/iris

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.