Skip to content

fix: parse activation response root element correctly#148

Open
Edgars-Ralfs-Dunis wants to merge 1 commit into
oisee:mainfrom
Edgars-Ralfs-Dunis:fix/activation-result-parsing
Open

fix: parse activation response root element correctly#148
Edgars-Ralfs-Dunis wants to merge 1 commit into
oisee:mainfrom
Edgars-Ralfs-Dunis:fix/activation-result-parsing

Conversation

@Edgars-Ralfs-Dunis

Copy link
Copy Markdown

Problem

Activate returns success: true, messages: [] even when SAP rejects the activation — the object silently stays inactive. Every workflow that trusts activation.Success (WriteSource, WriteClass, DeployFromFile, CreateTable, ActivatePackage — ~20 call sites) inherits the false positive. Verified on v2.38.1 and current main.

Repro: write a program with a syntax error via UpdateSource (so the pre-save check doesn't block), call Activate{"success": true, "messages": []}, but GetInactiveObjects shows the object still inactive.

Root cause

Replaying the activation POST with curl shows SAP does return the error — HTTP 200 with:

<chkl:messages xmlns:chkl="http://www.sap.com/abapxml/checklist">
  <msg objDescr="Program Z_ACT_TEST" type="E" line="1"
       href="/sap/bc/adt/programs/programs/z_act_test/source/main#start=2,6" forceSupported="true">
    <shortText><txt>Field "LV_UNDEFINED_VARIABLE" is unknown.</txt></shortText>
  </msg>
</chkl:messages>

parseActivationResult declares messages/inactiveObjects as child fields, but <chkl:messages> (or <ioc:inactiveObjects>) is the root element. xml.Unmarshal maps the root onto the target struct itself, so the parser looked for a <messages> child inside the root, matched nothing, decoded zero messages without error, and Success stayed true. (The sibling parseSyntaxCheckResults declares its structs one level deeper, which is why SyntaxCheck works.)

Fix

Declare the root's children (<msg> / <entry>) directly on the response struct — both known root forms parse with one struct since unmarshalling matches child local names.

Testing

  • New regression tests in pkg/adt/devtools_activation_test.go using a real payload captured from a NW 7.50 system: error-message root form, inactive-objects root form, empty-body success.
  • Red/green verified: all three tests fail against the previous parser, pass with the fix.
  • go vet ./pkg/adt clean.

The ADT activation response's ROOT element is <chkl:messages> (or
<ioc:inactiveObjects>), but parseActivationResult declared them as
child fields. xml.Unmarshal maps the root element onto the target
struct itself, so the parser silently found zero messages and
reported Success=true even when SAP rejected activation with
syntax errors (type="E" messages).

Declare the root's children (<msg> / <entry>) directly on the
response struct so both known root forms parse. Adds regression
tests using a real captured payload.
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