Skip to content

fix(srvb): unblock read for SRVB + correct inverted binding_category docs#149

Open
lin2qwer1-cloud wants to merge 2 commits into
oisee:mainfrom
lin2qwer1-cloud:fix/srvb-read-routing-and-category-docs
Open

fix(srvb): unblock read for SRVB + correct inverted binding_category docs#149
lin2qwer1-cloud wants to merge 2 commits into
oisee:mainfrom
lin2qwer1-cloud:fix/srvb-read-routing-and-category-docs

Conversation

@lin2qwer1-cloud

Copy link
Copy Markdown

Two independent SRVB defects found while building a RAP OData V4 service through the MCP surface against a live S/4HANA 2021 (SAP_BASIS 7.56) system. Both are small; the first one is what let the second one bite.

1. read SRVB is advertised but unreachable

GetSource's own tool description already lists SRVB (service binding) as a supported object_type, and pkg/adt implements it end to end (workflows_source.go case "SRVB"Client.GetSRVB → JSON). But the MCP router's allow-list in routeSourceAction omits "SRVB", so the call is rejected:

No handler found for action="read" target="SRVB"
Supported read targets: CLAS, PROG, INTF, FUNC, FUGR, INCL, DDLS, BDEF, SRVD, ...

Consequence: a caller can create a service binding but cannot read back what it actually got. This is what made defect 2 silent.

Fix: add "SRVB" to the read allow-list — no new capability, it just reaches the existing implementation and matches the documented contract.

Verified live:

before: No handler found for action="read" target="SRVB"
after : {"name":"...","type":"SRVB/SVB","published":false,
         "bindingType":"ODATA","bindingVersion":"V4","serviceDefName":"..."}

2. binding_category is documented backwards

Per SAP's domain SRVB_BND_CATEGORY (verified on 7.56 via DD07L/DD07T):

value meaning
0 UI ( User Interface )
1 A2X ( Application to X users ) — i.e. Web API

CreateObjectOptions, buildCreateObjectBody and the CreateObject tool schema all state the opposite ("0" for Web API, "1" for UI). A caller who wants a UI binding and follows the documentation passes "1" and silently gets an A2X/Web API binding.

The emitted default ("0") was already correct in practice — it produces a UI binding — only the label was wrong. Docs/semantics only, no behavior change.

Also clarified binding_version: it silently defaults to V2, producing a binding that cannot drive a Fiori Elements V4 app. Callers needing V4 must pass it explicitly; the schema now says so. (This is exactly how a binding named ..._O4 ended up as V2 for us, undetected because of defect 1.)

Tests

Added pkg/adt/crud_srvb_test.go pinning the ADT payload:

  • category: default → srvb:category="0", explicit UI 0, explicit A2X 1
  • version: default → srvb:version="V2", explicit V2 / V4
  • service definition bound and upper-cased, srvb:type="ODATA"

go vet clean. internal/mcp and pkg/adt suites pass.

Note: the Recording* tests in pkg/adt appear flaky on this machine independently of this change — they pass in isolation on both this branch and clean main, and across repeated full-suite runs different Recording* tests fail on unchanged code (2 of 3 runs fully green). Unrelated to this PR, flagging in case it is useful.

GetSource's own tool description lists "SRVB (service binding)" as a
supported object_type, and pkg/adt already implements it end to end
(workflows_source.go `case "SRVB"` -> Client.GetSRVB -> JSON). But the
MCP router's allow-list in routeSourceAction omits "SRVB", so every
`read SRVB <name>` is rejected with:

    No handler found for action="read" target="SRVB"

This makes a created service binding unverifiable through the MCP
surface: callers can create an SRVB but cannot read back which OData
version/category they actually got.

Add "SRVB" to the read allow-list. No new capability — this only lets
the existing, working implementation be reached, matching the tool's
documented contract.

Verified against a live S/4HANA 2021 (7.56) system:

    before: No handler found for action="read" target="SRVB"
    after : {"name":"YUI_FLIGHT_O4","bindingType":"ODATA",
             "bindingVersion":"V4","published":false,
             "serviceDefName":"YUI_FLIGHT_O4"}
The binding_category values were documented backwards. Per SAP's own
domain SRVB_BND_CATEGORY (verified on S/4HANA 2021 via DD07L/DD07T):

    0 = UI ( User Interface )
    1 = A2X ( Application to X users )   i.e. Web API

but CreateObjectOptions, buildCreateObjectBody and the CreateObject
tool schema all said the opposite ("0" for Web API, "1" for UI). A
caller who wants a UI binding and follows the documentation passes "1"
and silently gets an A2X/Web API binding instead.

The emitted default ("0") was already correct in practice — it produces
a UI binding — only its label was wrong, so this is a docs/semantics fix
with no behavior change.

Also clarify binding_version: it silently defaults to "V2", which yields
a binding that cannot drive a Fiori Elements V4 app. Callers who need V4
must pass it explicitly; the schema now says so.

Add regression tests pinning the ADT payload for category (default/UI/A2X),
version (default/V2/V4) and the bound service definition.
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