Skip to content

Persistence fix and PATCH endpoints for submodel elements#551

Open
tamasf1 wants to merge 3 commits into
eclipse-basyx:developfrom
rwth-iat:fix/persistence-and-patch
Open

Persistence fix and PATCH endpoints for submodel elements#551
tamasf1 wants to merge 3 commits into
eclipse-basyx:developfrom
rwth-iat:fix/persistence-and-patch

Conversation

@tamasf1
Copy link
Copy Markdown

@tamasf1 tamasf1 commented May 22, 2026

Mutations applied via PUT and PATCH endpoints were silently discarded.

The LocalFileIdentifiableStore reads objects from disk on every GET request and calls update_from() to refresh the in-memory cache. Because update_from() only mutates the in-memory object without writing back to disk, any changes made via PUT were silently overwritten on the next GET. As a result, PUT requests appeared to succeed (HTTP 204) but the repository state was never actually updated.

A new commit() method on LocalFileIdentifiableStore writes an Identifiable back to its storage file after mutation. The PUT and PATCH handlers in the repository interface now call commit() on the parent submodel after update_from() or value-only patching.

Additionally, six PATCH endpoints that previously returned 501 are now implemented:

  • PATCH /submodels/{smId}
  • PATCH /submodels/{smId}/$metadata
  • PATCH /submodels/{smId}/$value
  • PATCH /submodels/{smId}/submodel-elements/{path}
  • PATCH /submodels/{smId}/submodel-elements/{path}/$metadata
  • PATCH /submodels/{smId}/submodel-elements/{path}/$value

The $value PATCH handler covers Property, MultiLanguageProperty, Range, Blob, File, SubmodelElementCollection and SubmodelElementList. Complex element types (ReferenceElement, RelationshipElement) are not yet supported and return 400.

tamasf1 added 3 commits May 22, 2026 10:07
update_from() only mutated the in-memory object; the next GET re-read
the unchanged file from disk and overwrote the in-memory state, silently
discarding the update.

Add LocalFileIdentifiableStore.commit() to write an identifiable back to
its storage file, and call it from put_submodel and
put_submodel_submodel_elements_id_short_path after update_from().
Six routes were previously returning 501 Not Implemented:
- PATCH /submodels/{smId}
- PATCH /submodels/{smId}/$metadata
- PATCH /submodels/{smId}/$value
- PATCH /submodels/{smId}/submodel-elements/{path}
- PATCH /submodels/{smId}/submodel-elements/{path}/$metadata
- PATCH /submodels/{smId}/submodel-elements/{path}/$value

The plain and $metadata variants decode the full/stripped body and
call update_from. The $value variants use a new _apply_value_only
helper that applies a ValueOnly patch to the in-memory element tree.
All handlers call commit() to persist changes to disk.
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.

1 participant