Manifest best practices: Detect `serviceUrl` or `uri` under `/sap.ui5/models` and migrate to `/sap.app/dataSources`

Open
#1,145 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@flovogt is already working on this.

Since Oct 1, 2026.

Assessment

This issue has not been assessed yet.

Description

detection

Is your feature request related to a problem? Please describe.

For ODataModels, the data-source URL should be defined in a /sap.app/dataSources entry only, so that the URL can be correctly enriched (Currently by sap/ui/core/Component) with:

  • sap-context-token=...
  • sap-client=...
  • sap-language=...
  • sap-system=...
  • ...

Especially if a $metadata request includes the URL parameter sap-context-token but misses sap-client (scenario "A"), the app can break if the OData service/backend is strict about it therefore responds with 400 Bad Request.

According to Issues with OData Metadata Caching | SAP Help Portal:

Prerequisites for OData Metadata Caching

...

SAPUI5 Best Practices

The app itself needs to fulfill certain prerequisites. App developers need to make sure of the following criteria:

  • ...
  • The app must declare the OData services under sap.app/datasources.
  • The app must declare the SAPUI5 models under sap.ui5/models so that they are created.
    • The model must refer to the data source. It must not specify the URL directly (under sap.ui5/models).
    • ...
  • ...

Scenarios that result in either bypassing the data-source URL enrichment or breaking the app entirely:

Scenario Where Manifest / code Recommended severity
A manifest /sap.app/dataSources has the data-source, and the model under /sap.ui5/models references it correctly, but also unexpectedly sets serviceUrl or uri with the same source URL, violating the "must not specify the URL directly"-rule under /sap.ui5/models (Redeclared source wins --> sends $metadata?sap-context-token=... without sap-client --> 400 Bad Request depending on backend) Error
B manifest /sap.app/dataSources has the data-source, but the model misses referencing it via dataSource, uses serviceUrl / uri with the same source URL. Warning
C manifest /sap.app/dataSources doesn't include the data-source at all. The model's serviceUrl/uri is the only service definition. Warning
D JS An ODataModel is created imperatively instead of declaratively in the manifest - sometimes even re-created several times for the same service (often found in legacy apps) Warning

Besides the possible use of sap-context-token for client-side $metadata and annotation caching, maintaining and using /sap.app/dataSources (instead of serviceUrl under /sap.ui5/models) allows also:

Describe the solution you'd like

A rule that detects a service URL defined outside a /sap.app/dataSources-entry and encourages migration to dataSources.

E.g. for A-C scenarios:

{
  "sap.app": {
+    "dataSources": {
+      "myMainService": {
+        "uri": "/sap/opu/odata4/myservice/",
+        "type": "OData",
+        "settings": {
+          "odataVersion": "4.0",
           ...
  "sap.ui5": {
    "models": {
      "": {
+       "dataSource": "myMainService"  // "type" / "uri" / "settings" derived from the data source. URL gets enriched.
-       "type": "sap.ui.model.odata.v4.ODataModel",
        "settings": {
-         "serviceUrl": "/sap/opu/odata4/myservice/",
          ...

Optionally, local JSONModel/XMLModel could be migrated to dataSources too but I don't see a real benefit other than keeping more data sources consistently in /sap.app/dataSources.

Dominant language
TypeScript
Stars
82
Forks
14
Avg merge
10h 17m
Merged PRs (30d)
13

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 UI5/linter

All issues in UI5/linter

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.