Skip to content

BUG - Annotation Modeler: formatting corrupts an edm:String containing an entity, and xml:space is rejected #5029

Description

@xpr0gamers

Related Feature

Feature request: n/a

Description

The Annotation Modeler registers the DocumentFormattingEditProvider for annotation.xml.
When the document is formatted, it rewrites the text content of an edm:String that contains
an & entity: the text is split at the entity and padded with spaces.

For a literal that carries a URL this silently corrupts the annotation — the link generated at
runtime is broken, and nothing reports a problem at any point.

The standard XML mechanism to prevent this, xml:space="preserve", does work. However the same
extension then reports attribute-not-allowed-here on that attribute. xml: is reserved by the
XML specification and is permitted on any element, so this looks like a false positive: the
attribute validation appears to consider the EDMX schema only, with no notion of the reserved
namespace.

The two behaviours combine badly — the formatter corrupts the annotation, and the only
mechanism that stops it is flagged as an error.

Steps to Reproduce

  1. In a Fiori Elements app (OData V4), add a UI.DataFieldWithUrl whose Url is an
    odata.concat containing a literal with an entity reference:

    <Record Type="UI.DataFieldWithUrl">
        <PropertyValue Property="Value" Path="name" />
        <PropertyValue Property="Url">
            <Apply Function="odata.concat">
                <String>https://www.example.com/search/?api=1&amp;query=</String>
                <Path>name</Path>
            </Apply>
        </PropertyValue>
    </Record>
  2. Format the document — e.g. save it with editor.formatOnSave enabled.

  3. Look at the literal.

Expected results

The text content of an edm:String is preserved verbatim. It is data, not prose: any inserted
whitespace changes the value the annotation evaluates to.

xml:space="preserve" on an edm:String is accepted without a diagnostic.

Actual results

The literal is rewritten to:

<String>
    https://www.example.com/search/?api=1 &amp; query=
</String>

At runtime the URL becomes https://www.example.com/search/?api=1 & query=<value>. The query
parameter is therefore named query (with a leading space) and api has the value 1 , so
the target application receives neither parameter as intended. There is no warning anywhere —
the corruption is silent and only surfaces when a user clicks the link.

This is not driven by line length. It was first observed on a 104-character line; after
splitting the URL into two shorter literals to stay below the usual 100-character threshold, it
happened again on a 64-character line.

Adding xml:space="preserve" to the edm:String does stop the rewrite — verified over
repeated saves and a ui5 build, with UI5 parsing the annotation normally and the generated
URL correct. But the extension then reports:

'xml:space' attribute is not allowed here.   [attribute-not-allowed-here]

There appears to be no way to suppress this: the extension contributes only
sap.ux.annotationModeler.enableTelemetry (deprecated) and
sap.ux.annotationModeler.semanticHighlighting.enabled.

Suggested fix

  • Treat the content of edm:String as opaque when formatting — at minimum, never insert
    whitespace around an entity reference.
  • Accept attributes in the reserved xml: namespace (xml:space, xml:lang, xml:base)
    on any element, as the XML specification allows.

Screenshots

n/a

Version/Components/Environment

  • sapse.sap-ux-annotation-modeler-extension 1.30.0 (SAP Fiori tools extension pack 1.30.0)
  • VS Code on macOS 15
  • UI5 1.150.0, OData V4, Fiori Elements List Report / Object Page
  • redhat.vscode-xml is not installed, so formatting is performed by the Annotation Modeler
    itself and xml.format.* settings have no effect (VS Code reports those keys as unknown).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions