feat(adt): add INCL (PROG/I) write support for WriteSource, EditSource, CLI#121
feat(adt): add INCL (PROG/I) write support for WriteSource, EditSource, CLI#121frd1201 wants to merge 3 commits into
Conversation
…e, CLI Closes oisee#116. ABAP program includes were read-only — GetSource worked but WriteSource, EditSource, and CLI `source edit/write` rejected object_type=INCL. Core feature: - pkg/adt/workflows.go: new WriteInclude() — SyntaxCheck→Lock→UpdateSource→Unlock→Activate - pkg/adt/workflows_source.go: INCL in whitelist, existence check, create/update routing - pkg/adt/fileparser.go: .incl.abap extension → ObjectTypeInclude - internal/mcp/handlers_source.go: INCL in routeSourceAction, WriteSource/ImportFromFile/ExportToFile descriptions - cmd/vsp/devops.go: INCL in buildObjectURL() + CLI source edit/test/atc commands Bug fixes (program includes share /includes/ URL segment with class includes, causing three functions to misidentify them as class sub-resources): - pkg/adt/client.go: normalizeObjectURLForPackageCheck — don't strip /includes/NAME when prefix ends with /programs (was returning /sap/bc/adt/programs → SearchObject("PROGRAMS") → "package metadata not found") - pkg/adt/devtools.go: SyntaxCheck artifactURI — append /source/main for program includes (was sending object descriptor URL → SAP returned wrong content-type) - pkg/adt/workflows_edit.go: EditSourceWithOptions isClassInclude — require /oo/classes/ in URL (was setting sourceURL without /source/main → GET/PUT to XML endpoint → HTTP 406) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two bugs in INCL deploy flow (ImportFromFile / vsp deploy): 1. fileparser.go: .incl.abap files have no declaration statement, so the name must be extracted from the filename (same pattern as class includes). Without this, ParseABAPFile failed with "could not parse object name from file". 2. workflows_deploy.go: SyntaxCheck is stateless and was running after Lock (stateful), which broke the SAP session and caused HTTP 423 ExceptionResourceInvalidLockHandle. Moved SyntaxCheck to before Lock so the stateful session is established cleanly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c7890ea to
8f6c030
Compare
Merges PR oisee#121 (pending upstream) into fork/main so the fix is available locally. Will be removed from fork/main once upstream merges the PR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi! I opened PR #134 (now closed) targeting the same root cause described in #133, Since your fix covers the same ground and does more, I closed mine. The one thing func TestNormalizeObjectURLForPackageCheck(t *testing.T) {
cases := []struct {
input string
want string
}{
// Program includes (INCL) — must not be mangled
{"/sap/bc/adt/programs/includes/ZTEST_INCL", "/sap/bc/adt/programs/includes/ZTEST_INCL"},
{"/sap/bc/adt/programs/includes/ZTEST_INCL/source/main", "/sap/bc/adt/programs/includes/ZTEST_INCL"},
// Regular programs — unchanged
{"/sap/bc/adt/programs/programs/ZTEST/source/main", "/sap/bc/adt/programs/programs/ZTEST"},
// Class includes — strip to parent class
{"/sap/bc/adt/oo/classes/ZCL_FOO/includes/testclasses", "/sap/bc/adt/oo/classes/ZCL_FOO"},
{"/sap/bc/adt/oo/classes/ZCL_FOO/includes/definitions", "/sap/bc/adt/oo/classes/ZCL_FOO"},
// Class source — strip /source/main only
{"/sap/bc/adt/oo/classes/ZCL_FOO/source/main", "/sap/bc/adt/oo/classes/ZCL_FOO"},
}
for _, tc := range cases {
got := normalizeObjectURLForPackageCheck(tc.input)
if got != tc.want {
t.Errorf("normalizeObjectURLForPackageCheck(%q)\n got %q\n want %q", tc.input, got, tc.want)
}
}
}
Verified on-prem S/4HANA 758: matchCount: 1 reading ZREPORT_PRUEBA_TOP (package ZABAP01)
after the fix; write reaches SAP and returns corrNr not found instead of the pre-flight abort.
Also links to #133 for the on-prem reproduction case.
Also found the same overly-broad /includes/ check in SyntaxCheck() (devtools.go line 42) — program includes need /source/main in artifactURI or SAP can't locate errors. Same one-line fix: require /oo/classes/ alongside /includes/. |
…ee#121 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nts fixes Bug B — INCL write/update (issue oisee#116): - Add WriteInclude() workflow (SyntaxCheck→Lock→UpdateSource→Unlock→Activate) - Add INCL case in writeSourceCreate and writeSourceUpdate - Add INCL to WriteSource validation switch and exists check - Resolve INCL→PROG/I in CanonicalObjectType (removes TODO pending PR oisee#121) - Wire INCL in routeSourceAction MCP handler Bug A — DELETE session affinity (issue oisee#88): - Add DeleteObjectWithAutoLock(): tries accessMode=DELETE, falls back to MODIFY; performs lock+delete atomically in a single stateful session - Make lock_handle optional in handleDeleteObject; auto-lock path used when absent RunQuery / tableContents (previous session): - GetTableContents with sqlFilter now routes to freestyle endpoint (DDIC endpoint ignores request bodies) - Auto-constructs SELECT * FROM <table> WHERE <filter> when filter is not a full SELECT - Add panic recovery in callHandler so internal panics surface as tool errors (not -32603) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks @txape10 — added |
Closes #116
Summary
WriteInclude()workflow — full SyntaxCheck → Lock → UpdateSource → Unlock → Activate cycle for ABAP program includesobject_type="INCL"(MCP tools and CLIvsp source write/edit)vsp source edit INCL— CLI surgical string replacement for includesDeployFromFile/ImportFromFile—.incl.abapfile extension recognized; object name extracted from filename (includes have no declaration statement)/includes/URL segment that caused program includes to be misidentified as class sub-resources:normalizeObjectURLForPackageCheck: was stripping/includes/NAMEfrom program include URLs →SearchObject("PROGRAMS")→ "package metadata not found"SyntaxCheckartifactURI: was missing/source/mainfor program includes → SAP returned wrong content-typeEditSourceWithOptionsisClassInclude: was missing/source/mainin sourceURL → GET/PUT to XML object descriptor endpoint → HTTP 406UpdateFromFile— stateless SyntaxCheck between stateful Lock/Write broke the SAP session (HTTP 423 ExceptionResourceInvalidLockHandle)Test plan
GetSource(object_type="INCL", name="ZZ_FABD1_DUSH8_CICD2")— read worksWriteSource(object_type="INCL", name="ZZ_FABD1_DUSH8_CICD2", source="...", mode="upsert")— create and update worksEditSource(object_url="/sap/bc/adt/programs/includes/ZZ_FABD1_DUSH8_CICD2", old_string="...", new_string="...")— surgical edit worksvsp source read INCL ZZ_FABD1_DUSH8_CICD2— CLI read worksvsp source write INCL ZZ_FABD1_DUSH8_CICD2 < file.abap— CLI write worksvsp source edit INCL ZZ_FABD1_DUSH8_CICD2 --old "..." --new "..."— CLI edit worksImportFromFile(file_path="zz_test.incl.abap")— deploy from file works (Updated PROG/I ZZ_FABD1_DUSH8_CICD2, activated)