fix(schema): make number_pool_id a read-only NumberPool parameter

Merged
AJ
2d ago
+2-5

Human summary

we want to block/ignore changes to parameters.number_pool_id on NumberPool attributes in the schema. only Infrahub should modify this value.

Why

A team that loads a schema containing the number_pool_id of a NumberPool attribute can end up with an attribute that points to a pool that does not exist. This happens with a schema exported from another instance, or with an attribute copied from an existing one. If the attribute has no pool yet, the server stores the submitted id. The schema synchronizer then never creates a pool for the attribute, and every create of that kind fails (IFC-3381).

Only the server's schema synchronizer should assign this id. This PR makes number_pool_id a read-only field of the write contract. The Infrahub server already drops read-only fields on a schema load and returns a warning for each one.

Closes IFC-3381 together with opsmill/infrahub#11297.

What changed

  • NumberPoolParametersWrite no longer declares number_pool_id.
  • READ_ONLY_FIELDS lists number_pool_id for NumberPoolParametersWrite. Validating a schema file that sets it reports 'parameters.number_pool_id' is a read-only field, the submitted value is ignored. It is no longer accepted as a writable field.
  • NumberPoolParametersRead still has number_pool_id, so reading a schema from the server still returns the pool id.

How to review

Both files under infrahub_sdk/schema/generated/ are generated by uv run invoke backend.generate in the Infrahub repository, from tasks/backend.py. The generator change is in opsmill/infrahub#11297.

Impact & rollout

  • Backward compatibility: a schema file that sets number_pool_id still validates, with a warning in place of silent acceptance.
  • Deployment notes: merge before opsmill/infrahub#11297, which moves its python_sdk pointer to the merged commit.

Checklist

  • Tests added/updated (in opsmill/infrahub#11297)
  • Changelog entry added (changelog/+number-pool-id-read-only.changed.md)
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)

šŸ¤– Generated with Claude Code