fix(eam): read the instance name from SRM's ref

flowchart LR
  SRM["SRM GET /internal/service-instances<br/>{service_instance_id, ref: podinfo_bcn_1610, ...}"]
  -->|"before: reads name (absent) → None"| X["AppInstanceInfo.name = instance id"]
  SRM -->|"now: reads ref"| Y["AppInstanceInfo.name = podinfo_bcn_1610"]

GET /appinstances gave every instance its UUID as name. SRM's listing has no name field; it carries the requested name as ref, which is what oeg/app-instance-flow.md maps CAMARA name to (service_instance.ref, via the SRM proxy read). SRMServiceInstance read name, always got None, and the mapper fell back to the id.

No test caught it because the fakes build SRMServiceInstance(name=...) directly. The field now validates from ref and keeps name as an alias, so the fakes stay as they are. A new test_srm_client.py case parses SRM's actual response shape.

This fixes local instances by itself. For instances a partner hosts, FM also has to return the name as ref, which is FM MR fix/partner-instance-name.

Result
unit tests 1265 passed, 1 skipped; mypy, ruff clean
new test without the fix fails: assert None == 'podinfo_bcn_01'
testbed, ns oop, OP-1 Barcelona (local) and Paris (on OP-2) instances listed by name, both ready

1-both-named

The two rows still showing a UUID are partner instances deployed before the FM fix.

🤖 Generated with Claude Code

Merge request reports

Loading
+3 −2
Changes for src/open_exposure_gateway/domain/edge_application_management.py: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ from enum import StrEnum
from typing import Any, Literal
from uuid import UUID

from pydantic import BaseModel, Field, model_validator
from pydantic import AliasChoices, BaseModel, Field, model_validator


class Subject(StrEnum):
@@ -349,7 +349,8 @@ class SRMServiceInstance(BaseModel):
    state: str
    app_provider_id: str
    zone_id: str | None = None
    name: str | None = None
    # SRM keeps the requested instance name as the instance's ref
    name: str | None = Field(default=None, validation_alias=AliasChoices("ref", "name"))
    capability_instances: list[SRMCapabilityInstanceSummary] = []


+18 −0
Changes for tests/unit/test_srm_client.py: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -289,6 +289,24 @@ async def test_get_app_instances_sends_app_provider_id_query_param(
    assert captured["params"] == {"app_provider_id": "provider-1"}


async def test_app_instance_name_is_read_from_srms_ref(monkeypatch: pytest.MonkeyPatch) -> None:
    srm_instance = {
        "service_instance_id": "0e2f6c1a-5b7d-4c8e-9f10-2a3b4c5d6e7f",
        "service_specification_id": "7d1e2f3a-4b5c-4d6e-8f90-1a2b3c4d5e6f",
        "zone_id": "3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
        "state": "active",
        "ref": "podinfo_bcn_01",
        "app_provider_id": "provider-1",
        "metadata": {},
        "capability_instances": [],
    }
    client = _client(monkeypatch, lambda request: httpx.Response(200, json=[srm_instance]))

    [instance] = await client.get_app_instances(app_provider_id="provider-1")

    assert instance.name == "podinfo_bcn_01"


@pytest.mark.parametrize(
    "body",
    [
Loading