Repository navigation
feat(mx_execute): forward outlogds to the SASjs Server trigger - #476
Conversation
mx_execute takes outlib/outref so a caller can capture what the child returned, but not outlogds - the parameter that ms_testservice uses to keep the child's SAS log. On SASjs Server the server appends the log to the response after the log separator, and ms_testservice chops it away unless outlogds is given, so the log is unreachable through mx_execute even with debug=log set. The parameter is passed through only on the SASJS branch, which is the only platform whose trigger returns a log; the other branches ignore it. Default _null_ means existing callers see no change. Needed by Data Controller's test harness, which wants the child's log available on demand (mdebug) and now discards it.
There was a problem hiding this comment.
Reviewed the full base...head diff of #476: macro signature addition, type/comments pass-through, regenerated all.sas, downstream callee support, commit type, CI state.
- tests/x-platform/mx_execute.test.sas: new behaviour with no test update. The outlogds argument is only meaningful on the SASJS branch, and the existing x-platform test does not exercise it, so the forwarding path - the actual subject of the change - has no coverage. Add a SASjs Server case that passes outlogds= and asserts the log dataset is populated on return, mirroring the pattern in tests/serveronly/ms_testservice.test.sas.
- xplatform/mx_execute.sas: the parameter is silently dropped on the SAS9 and Viya branches. The doc marks it "SASjs Server only", which covers the intent, but a NOTE (or an explicit warning) when outlogds is set on those platforms would save a caller from a silent no-op.
1 finding above for review.
Two cases: the child's webout is returned and its log captured when outlogds is supplied, and the default call still returns the webout without writing a log dataset.
mx_execute already collects the job log on Viya (mv_jobflow outref) and prints it; write those lines to outlogds as well, so the parameter behaves the same way on both platforms that can return a log. SAS 9 stays out: proc stp returns no child log.
Extends the existing x-platform test rather than adding a server-only one: mx_createwebservice already builds the child on every platform, and outlogds now behaves on Viya as well as SASjs Server. Test 2: the default call writes no log dataset (existing callers unaffected). Test 3: with outlogds the child's log is captured - asserted on its own %put - skipped on SAS 9, where proc stp returns no log. Guarded in a macro so the %if never sits in open code.
There was a problem hiding this comment.
Reviewed the full base...head diff (xplatform/mx_execute.sas, all.sas bundle, tests/x-platform/mx_execute.test.sas) plus the CI state at this head. Scope note: the SASjs Server side of outlogds lives in ms_testservice, outside this repo, so it is accepted on trust.
- xplatform/mx_execute.sas:263 the new capture step never reads a record:
data &outlogds; infile &fref1 lrecl=2000; length line $2000; line=_infile_; run;has no INPUT statement, unlike the log-echo block immediately above it (line 257-259,infile &fref1; input; putlog _infile_;). INFILE is only populated by an INPUT statement, so this step yields an empty or single blank-row dataset, not the job log. Addinput;beforeline=_infile_;. - xplatform/mx_execute.sas:264
lrecl=2000silently truncates long records, and Viya job logs regularly exceed that per line. The other readers in this macro uselrecl=32767(see the inputfiles parser); match that and make itlength line $32767so the captured log is the log. - tests/x-platform/mx_execute.test.sas:92 Test 3 returns early whenever
%mf_getplatform()is SAS9, which is the only platform the suite exercises on a non-Viya CI lane, so the new capture path has no executed assertion unless the Viya lane ran at this head. Since the missing INPUT above would be caught by that assertion, state which lane covered it (or note it as unverified) rather than relying on a green run.
2 findings above for review.
The Viya branch passed outds=work.results to mv_jobflow and then read it back for the uri, leaving a fixed-name table in the caller's session. That name then looked like an output of mx_execute and callers started reading it - it is an internal detail of the job flow. Use mf_getuniquename for the table, read the uri from it, and delete it before returning, so nothing with a predictable name is left behind.
There was a problem hiding this comment.
Reviewed the full diff - outlogds plumbing through mx_execute on both the Viya and SASjs Server paths, the jobflow table rename, and the added tests. CI is green.
- xplatform/mx_execute.sas:265-270 (mirrored in all.sas): the new capture step reads &fref1 into &outlogds but has no INPUT statement, so INFILE is never populated from the file and the dataset receives blank rows instead of the child log. Add
input;beforeline=_infile_;, the same way the show-log step directly above does. Regenerate all.sas after the fix rather than hand-editing it. - xplatform/mx_execute.sas:266-268 (mirrored in all.sas):
lrecl=2000combined withlength line $2000truncates any child log line longer than 2000 bytes, silently. Raise the length or state the truncation limit in the @PARAM doc so callers know the log can be cut.
2 findings above for review.
Reading work.results was the only way for a caller to learn whether the child completed or was cancelled - an accident of the Viya branch's internal flow table, which callers then depended on. Give that a supported home. outstatus= writes one row per program: STATE, URI, ERRMSG, PLATFORM. - Viya: state and uri from the job flow, before the internal table is dropped - SASjs Server: state derived from the response - a sasjsAbort block means canceled - with the abort message in ERRMSG - SAS 9: unknown, with a note in ERRMSG; proc stp returns no job status The SASjs branch keeps a private response fileref when the caller asked only for the status, and clears it afterwards.
There was a problem hiding this comment.
Reviewed the full base...head diff of xplatform/mx_execute.sas with all.sas in step plus the x-platform tests. Verified against the head tree that server/ms_testservice.sas already takes outlogds with a line:$2000 shape and that viya/mv_jobflow.sas really does return STATE and URI, so the parameter plumbing and the keep=state uri read are sound. SAS 9 and Viya paths are static-only here - the SAS9/Viya branches are not exercised by any run I could see.
- xplatform/mx_execute.sas: the removal of the fixed work.results table is a breaking change for any caller that reads it after the call, and the doc comment admits the intent ("This is the supported replacement for the fixed work.results table the Viya branch used to leave behind"), but the subject is feat(mx_execute) with no breaking marker. As it stands semantic-release cuts a minor and the break ships silently. Use feat(mx_execute)!: or a BREAKING CHANGE: footer, and add the entry to README's Breaking Changes section.
- xplatform/mx_execute.sas, SASjs branch status step: the row is only written from inside the read (
if eof then output;afterinput;), so an empty or blank _webout produces a zero-observation &outstatus instead of the 'completed' row the doc promises, and a caller reading the table learns nothing. Create the row unconditionally - retain the defaults and output once after the loop regardless of whether any record was read. - xplatform/mx_execute.sas, SASjs branch: errmsg is taken with prxchange('s/.?"MSG":"([^"])".*/$1/',-1,infile) with no match test, so a record that contains "sasjsAbort" but no MSG field leaves the whole raw line (chopped at 256) in errmsg - a false message rather than the real one or empty. Guard on prxmatch for the MSG field and set a fixed fallback text otherwise. The same
input;-per-record read also only sees one record, so a pretty-printed response with sasjsAbort and MSG on separate lines reports state='completed'. - xplatform/mx_execute.sas, Viya branch outlogds:
infile &fref1 lrecl=2000;withlength line $2000truncates every Viya job-log record past 2000 characters, and a truncated log reads as complete. Use the same lrecl as the rest of the Viya read (32767) or mp_chop the records deliberately, and say in the doc comment which.
4 findings above for review.
…cros A macro defined inside a test program is not registered by the runner - the run ended with 'Missing %MEND statement for macro MP_TEST_ABORT'. Replace both guarded cases with ordinary code that computes its own verdict, and add mcTestPlatform to the test init so a test can vary its expectation by platform without an %if. Test 3 now expects the log on Viya and SASjs Server and is satisfied without one on SAS 9; Test 5 expects state=canceled, or unknown on SAS 9 where proc stp reports no job status.
'Macro parameter contains syntax error' was reported at the next macro call, not at the assertion that carried it - the quote in "child's" left the parameter unbalanced.
There was a problem hiding this comment.
Reviewed the full base...head diff of #476 - xplatform/mx_execute.sas with its all.sas build copy, and the x-platform test suite.
-
tests/testinit.sas:39 -
%let _sasjs_apiserverurl=http://127.0.0.1:5000;is committed under a comment that reads "TEMP - local run only, not for commit". testinit.sas is shared by every runner and every platform, so this pins the whole suite at one developer's localhost and overrides the estate's own server URL. Drop it before merge; if a local override is genuinely needed, have the runner supply it through an environment variable. -
xplatform/mx_execute.sas:353-355 - the SASjs branch clears the response fileref under
%if "&outref"="0" %then %do; filename &respref clear; %end;, butresprefonly gets a real fileref when outstatus was also requested. With the documented defaults (outref=0,outstatus=0) the guard is true and respref is still the literal0, so the most common invocation runsfilename 0 clear;, which is not a valid fileref and errors. Guard the clear with the same condition that creates the fileref ("&outref"="0" and "&outstatus" ne "0"), and add a test that calls mx_execute with neither outref nor outstatus - every new test passes outref, so the default path is untested. -
tests/x-platform/mx_execute.test.sas:130 (Test 3) -
foundis set to 1 whenever the platform is SASMETA, before work.childlog is read, so on SAS 9 the assertion passes without a log having been produced anywhere. The platform behaviour is defensible, but the assertion text claims the log was captured; either narrow the description for that platform or assert childlog does not exist there, so the test states what it actually proves.
3 findings above for review.
There was a problem hiding this comment.
Reviewed the delta from f513faa to 0ef1e8d (one assertion description reworded) plus the outstanding findings still present at this head. Two items.
- tests/testinit.sas:38:
%let _sasjs_apiserverurl=http://127.0.0.1:5000;is committed with the comment "TEMP - local run only, not for commit". It runs after %mp_init() in every suite run, CI included, so it overrides the API URL the run was configured with and points the tests at localhost, where nothing listens. Remove the line; if a local override is needed, take it from an environment-supplied macro variable that CI does not set. - xplatform/mx_execute.sas (SASjs Server branch):
%if "&outref"="0" %then %do; filename &respref clear; %end;is true on the default call (outref=0, outstatus=0), where &respref is also 0, so it emitsfilename 0 clear;- an invalid fileref and an error in the child log. Clear only a fileref this macro created: addand "&outstatus" ne "0"to the guard (the condition that allocated it), or track the created ref explicitly.
Tests were not executed from the review box (no SAS/Viya session available), so the SAS 9, Viya and SASjs Server branches are reviewed statically only.
2 findings above for review.
The server validates _debug as a number, so the 'log' default never asked for a log: the response came back without one, mp_chop found no separator, and callers asking for outlogds got an empty dataset. 131 matches ms_runstp's own default. Also drops the explicit debug=log from the test calls so they exercise the default.
There was a problem hiding this comment.
Reviewed the base...head diff of xplatform/mx_execute.sas, all.sas and the x-platform test suite: outlogds/outstatus are added on all three platform branches, work.results is replaced by a uniquely named flow table, and writeback/all.sas match the source.
- tests/testinit.sas:37 -
%let _sasjs_apiserverurl=http://127.0.0.1:5000;is committed under a comment saying "TEMP - local run only, not for commit". It overrides the suite's API URL for every run on every platform, so a CI or developer run silently talks to localhost instead of the configured server. Remove it, or have the local harness set it from the environment outside the committed file. - xplatform/mx_execute.sas:349 -
%if "&outref"="0" %then %do; filename &respref clear; %end;runs in the default path, where outref=0 and outstatus=0 leave &respref as the literal 0 and no fileref was ever generated. That clears a fileref named "0", which is not a valid fileref name, so the default call errors in the log. Test on the generated ref instead: set a flag when %mf_getuniquefileref runs and clear only then (or guard on &respref ne 0). - xplatform/mx_execute.sas:284 - the Viya branch copies the child log with
infile &fref1 lrecl=2000; length line $2000;while the SASjs branch uses 32767. Viya job logs routinely exceed 2000 bytes, so the returned work.outlogds is silently truncated. Use the same lrecl and length as the other branch. - xplatform/mx_execute.sas:72 -
debug=131replaces thedebug=logdefault, changing the child's debug setting for existing callers who pass nothing. The parameter text explains why, which is fine, but it is a behaviour change to a public macro default: say so in the PR body / release notes as breaking rather than only in the parameter doc. - consistency, xplatform/mx_execute.sas:279 - the Viya log branch tests
%if &outlogds ne _null_unquoted while every other comparison in the macro quotes its operands ("&outstatus" ne "0"). Quote it so a caller-supplied name cannot be evaluated as a numeric operand.
5 findings above for review.
There was a problem hiding this comment.
Reviewed the full base...head diff: the outlogds/outstatus additions in xplatform/mx_execute.sas, the ms_runstp log-chop change, the generated all.sas mirror, and the new tests.
- tests/testinit.sas:37-39: a local-only override is committed to the shared test init -
%let _sasjs_apiserverurl=http://127.0.0.1:5000;under a comment that says "TEMP - local run only, not for commit". Every suite run on every platform will now call 127.0.0.1 instead of the estate's API server. Remove it before merge. - xplatform/mx_execute.sas:337-340: in the SASjs Server outstatus step only
stateis retained;errmsgis not. The message captured from a sasjsAbort line is therefore reset to missing by the next input and survives only if the abort block happens to be on the final line - and the dataset is output only at eof, so the abort message is normally lost. Retain errmsg too, or output on the abort line and stop. - xplatform/mx_execute.sas:348: the clear is guarded by
%if "&outref"="0"but clears&respref. respref is only promoted to a real fileref when outstatus ne 0, so the plain default call (outref=0, outstatus=0) falls through tofilename 0 clear;. Guard on &respref instead. - server/ms_runstp.sas:194 (and the all.sas copy): the justification does not match what mp_chop does. mp_chop matches only the FIRST occurrence (base/mp_chop.sas stops at the first match), so matchpoint=END with keep=LAST already kept everything after that first separator, i.e. the log; matchpoint=START with keep=LAST keeps from one byte before the match, so the log dataset now begins with the separator line itself. If a trailing separator is the actual problem, strip it explicitly rather than moving the chop point, and fix the comment.
- xplatform/mx_execute.sas:72: changing the public default
debugfrom log to 131 changes the value sent to the server for every caller that omitted it. Nothing in-repo passes debug=log, but this is a default change on a public macro - consider feat!/BREAKING CHANGE so it releases as a major, and cover it in the PR description, which currently only mentions outlogds.
5 findings above for review.
1ba919b to
cfb2077
Compare
|
Status after running it against a SASjs Server estate (deployed to
Two things I got wrong on the way, recorded so nobody repeats them:
Also changed here: Not yet merge-ready: Test 3/5 need the log path resolved (or the assertions marked as known-broken on servers that return no log section), and the Viya branch still has no run behind it. |
There was a problem hiding this comment.
Reviewed the full diff at this head: mx_execute outlogds/outstatus in xplatform/mx_execute.sas and all.sas, plus the x-platform test additions.
- tests/testinit.sas:38 -
%let _sasjs_apiserverurl=http://127.0.0.1:5000;is committed with its own comment saying "TEMP - local run only, not for commit". Every run of the suite now points at a localhost API server, so it breaks anywhere the SASjs Server is not on 127.0.0.1:5000. Remove the line and take the URL from the environment or CI configuration. - xplatform/mx_execute.sas:283 (mirrored at all.sas:33138) - the Viya outlogds step has no INPUT statement:
infile &fref1 lrecl=2000; length line $2000; line=_infile_;. No record is read, so outlogds comes back empty and the documented contract ("kept when mdebug is on") only holds on SASjs Server. Read it in a loop the way the null step immediately above does:do while(not eof); input; output; end;withend=eofon the INFILE. - xplatform/mx_execute.sas:288 (and all.sas) -
%if &outlogds ne _null_compares an unquoted text value. A dataset name contains a period, so SAS attempts to resolve &work before the comparison and emits "Apparent symbolic reference WORK not resolved" on every call, and literal whitespace or a two-level name compares unpredictably. Use%if "%outlogds" ne "_null_". - Breaking change, and the release type misstates it: the Viya branch no longer leaves work.results in the caller's WORK (outds=work.results became a unique jobds that is deleted). Any existing caller that reads work.results after mx_execute now errors, and at least one downstream repo is doing exactly that. The title is
feat(mx_execute): ..., which cuts a minor release; this needsfeat!:or aBREAKING CHANGE:footer plus a migration note naming outstatus as the supported replacement. - tests/x-platform/mx_execute.test.sas (Test 3) -
if exist('work.childlog') then do until(eof); set work.childlog ...cannot guard anything: SET is compiled whether or not the IF is true, so on SAS 9, where no log dataset is written, the step fails to compile before the SASMETA branch above can pass. Wrap the whole DATA step in %if %sysfunc(exist(work.childlog)) %then, or create the empty dataset first. - tests/x-platform/mx_execute.test.sas (Test 4) -
if not exist('work.status5') then stop; set work.status5;has the same shape; the existence test does not prevent the SET from being compiled against a dataset that may not exist. - tests/x-platform/mx_execute.test.sas (Test 5) - the test deploys abortObj into &mcTestAppLoc/services and leaves it there: a repeated run silently rewrites it, and the deployment needs write access the read-only tests do not, so the suite's own footprint grows with every run. Deploy into a test-owned folder and delete the service at the end.
7 findings above for review.
The outlogds data step did line=_infile_ with no INPUT statement, so the chopped log file was never read: _infile_ stayed empty and the step wrote a single missing row. outlogds then looked like an empty log rather than the child's. Verified against a live response - the log sits between two separators, 852 lines for a simple service, and mp_chop keeps it correctly (it matches the first occurrence only, so the trailing separator is irrelevant).
There was a problem hiding this comment.
Reviewed the full base...head diff of #476 (mx_execute outlogds/outstatus, ms_runstp log fix, test suite) - re-review at the new head, findings below are on the current diff.
-
xplatform/mx_execute.sas:285-289 - the new Viya outlogds data step reads &fref1 but never calls INPUT:
infile &fref1 lrecl=2000; length line $2000; line=_infile_;leaves infile empty, so outlogds gets a single blank row instead of the job log and the file is never advanced. This is the exact defect this PR fixes in ms_runstp.sas and all.sas; addinput;beforeline=_infile_;. Fix in xplatform/ (all.sas appears generated by build.py) and rebuild so both copies match. -
tests/testinit.sas:37-39 - committed scaffolding:
%let _sasjs_apiserverurl=http://127.0.0.1:5000;under a comment reading "TEMP - local run only, not for commit". It overrides the API URL for every test run, forces plaintext HTTP, and only works on a host where the API answers on loopback. Remove it before merge. -
xplatform/mx_execute.sas:334-346 - the SASjs outstatus step derives state solely from the literal
sasjsAbortin the response, so any other failure response (HTTP error, non-JSON body, service rejected before running) is reported ascompleted. The errmsg extractionprxchange('s/.*?"MSG":"([^"]*)".*/$1/',...)also truncates at the first escaped quote inside MSG. Broaden failure detection or document the limitation in the @PARAM block. -
Breaking changes are understated in the commit type. Dropping the fixed
work.resultstable (Viya) and changing thedebugdefault fromlogto131are both visible to callers; they are documented in @PARAM outstatus but the commit is typedfeat, so if releases are cut from commits this ships as a minor. Needsfeat!/ aBREAKING CHANGE:footer, or an explicit release note.
4 findings above for review.
A child that aborts before its response is opened returns HTTP 200 with a truncated webout and no abort block anywhere in body or log, so there is nothing for outstatus to report. Opening the webout first reproduces the behaviour of the services this is meant to measure.
mx_createwebservice defaults to ft15f001, which still held the sendObj source, so the 'aborting' service was a byte-for-byte copy of the service that succeeds - the abort case was never exercised at all.
There was a problem hiding this comment.
Reviewed the full base...head diff (xplatform/mx_execute.sas, all.sas, server/ms_runstp.sas, tests/testinit.sas, tests/x-platform/mx_execute.test.sas). CI is green.
- xplatform/mx_execute.sas:285-289 (also all.sas) - the new Viya outlogds step repeats the bug this PR fixes in ms_runstp:
infile &fref1 lrecl=2000; length line $2000; line=_infile_;has noinput;, so the file is never read and the dataset ends up as one row of missing values. Addinput;beforeline=_infile_;, exactly as done for chopout. - xplatform/mx_execute.sas:284 -
%if &outlogds ne _null_ %thencompares unquoted tokens; both the default_null_and anywork.xvalue are non-numeric, so %EVAL raises a character-operand error and the Viya branch dies before the log is captured. Use%if "&outlogds" ne "_null_", matching the quoted comparisons used for outstatus. - tests/testinit.sas:37-38 - a block explicitly marked "TEMP - local run only, not for commit" is in the commit:
%let _sasjs_apiserverurl=http://127.0.0.1:5000;pins every SASjs Server run of the suite to 127.0.0.1:5000, which will not hold in CI or on any other host. Remove it before merge. - xplatform/mx_execute.sas:338-345 - the SASjs outcome step reads one record (single
input;beforeif eof then output), so a sasjsAbort block past the first line of the response is never seen and state stays 'completed' - a false success. Scan to EOF, or read the whole response into one variable, before deciding the state. - Commit type -
feat(mx_execute)understates the change: the debug default moves fromlogto131and the Viya branch no longer leaveswork.resultsbehind, so existing callers see different behaviour. Make itfeat(mx_execute)!or add a BREAKING CHANGE footer naming both, otherwise semantic-release cuts a minor.
5 findings above for review.
There was a problem hiding this comment.
Reviewed the full base...head diff at a21bf9c (re-review; CI green): outlogds/outstatus in mx_execute and ms_runstp, the SASjs Server forwarding, and the new x-platform tests.
- xplatform/mx_execute.sas:288 - the Sasviya outlogds step is
infile &fref1 lrecl=2000; length line $2000; line=_infile_;with noinput;, so infile is never populated and the dataset comes back as a single blank row instead of the job log. This is the same defect fixed in ms_runstp.sas in this PR; apply the same fix here (and regenerate all.sas). As written, the new outlogds feature is inert on Viya and test 3 only proves it on SASjs Server. - tests/testinit.sas:39 -
%let _sasjs_apiserverurl=http://127.0.0.1:5000;is marked TEMP/local-only in its own comment and must not merge: it points every runner's suite at localhost and overrides whatever the target config sets. - xplatform/mx_execute.sas:72 - changing the debug default from
logto131silently changes _debug for every existing caller. The reason (the server validates it numerically) is sound, but say so in the release notes so callers relying on the old value know their log volume changed.
3 findings above for review.
…always Review findings, all of them real: - the Viya outlogds step had no INPUT, so the job log was never read - the same defect fixed in ms_runstp, in the other branch; - `%if &outlogds ne _null_` compared unquoted tokens, so a value like work.x raised a character-operand error before the capture ran; - lrecl/length of 2000 truncated Viya job log lines; both branches now use 32767 like the other readers in this macro; - the SASjs outstatus step read a single record, so an abort block on any later line was missed and reported as completed, and errmsg was not retained; - the response fileref was cleared on the default path, where outref=0 left %respref% as the literal 0, so the commonest call ran `filename 0 clear;`. Also removes a localhost override that was committed to tests/testinit.sas under a comment saying it was not for commit, and adds Test 6, which exercises the documented defaults - no outref, outlib or outstatus - the path none of the other cases covered.
Test 3 leaves work.childlog in the session, so asserting the default call writes no log was really asserting on Test 3's leftovers.
|
Superseding my earlier status comment - the PR is now 12 of 12 assertions passing on a SASjs Server estate (
What the earlier failures actually wereTwo defects, both mine, neither in the subject of the change:
I also wrongly concluded from that, mid-investigation, that the estate does not return an abort block. It does; the service simply never aborted. Testing beat guessing, twice. Review findings addressedAll of the substantive ones were real and are fixed in
Not a breaking changeYou flagged the |
|
Test run on a SASjs Server estate, at
|
| Result | Description |
|---|---|
PASS |
No errors after service creation |
PASS |
somedata1 created correctly |
PASS |
somedata2 created correctly |
PASS |
Test 2 - no log dataset is written unless outlogds is asked for |
PASS |
Test 3 - the child log is captured when outlogds is supplied |
PASS |
Test 4 - a clean run reports state=completed |
PASS |
Test 4 - no fixed-name table is left in the caller WORK |
PASS |
Test 5 - an aborted child reports its outcome |
PASS |
Test 5 - the abort message from the child is reported |
PASS |
Test 6 - the default call runs without error |
PASS |
Test 6 - the default call leaves no log or flow table behind |
PASS |
Checking final err condition |
Notes on reproducing
- The estate cannot validate its own public certificate from inside a SAS session, so the run needs
%let _sasjs_apiserverurl=http://127.0.0.1:5000;before the tests call the API on themselves. That is a property of this estate, not of the change, and it is not committed - it is injected into the build for the run and reverted before committing. - The SAS 9 and Viya branches are still not exercised by a run; everything above is the SASjs Server path.
There was a problem hiding this comment.
Reviewed the full diff (mx_execute + ms_runstp source, regenerated all.sas, tests). The input; fix, the unique flow-table and the respref/clear handling look right; findings are about what the new outputs promise versus what callers actually get.
- xplatform/mx_execute.sas:338 (SASjs branch) - outlogds is forwarded to ms_testservice with the caller's debug unchanged, but ms_testservice only returns the response log at debug 131 or above (its own doc says the separator outlogds chops on exists only in debug mode). A caller who passes outlogds with a lower debug gets an empty or missing log and no indication why. Either raise/force debug when outlogds is requested, or state the debug>=131 dependency in the mx_execute outlogds doc.
- xplatform/mx_execute.sas:72 - the debug default moves from log to 131, changing what existing callers get back from the STP, and the Viya branch no longer leaves work.results behind (xplatform/mx_execute.sas:306). The latter is documented but is a breaking change for any downstream code reading work.results, while the commit subject is plain feat(mx_execute). Use feat! / a BREAKING CHANGE footer so the removal lands in the release notes and the version bump.
- xplatform/mx_execute.sas:341-356 - errmsg is set from any response line containing "MSG", so a service that returns a field named MSG (or logs a line quoting "MSG": "...") produces a spurious abort message, and with several such lines the last one wins. Scope both the state and the message extraction to the sasjsAbort block rather than scanning every line.
- xplatform/mx_execute.sas:201-208 - on SAS 9, outlogds is requested but silently produces nothing, so the caller cannot distinguish "platform has no child log" from "log came back empty". A %put note when outlogds is set on that branch would make the documented limitation visible at runtime.
- xplatform/mx_execute.sas:325 - %if "%outlogds" ne "null" dereferences with %outlogds while the neighbouring tests use &outstatus; use &outlogds for consistency with the rest of the macro.
5 findings above for review.
…a log is empty - errmsg was taken from any line containing "MSG", so a service with its own MSG field - or a log line quoting one - produced a spurious abort message, and the last such line won. The message is now only read once the sasjsAbort block has been seen, and only while errmsg is still blank; - outlogds is documented as needing debug 131 or above: the server only appends the log to the response in debug mode, so a lower value returns an empty dataset with no explanation; - the SAS 9 branch now says so in a NOTE when outlogds is requested, instead of silently returning nothing; - the outlogds comparison dereferences &outlogds like the neighbouring outstatus checks, rather than %outlogds.
|
On the two items that keep coming up, so the position is on the record. Not a breaking change - staying
So both changes move behaviour from "did not work as advertised" to "works as documented". I have added a line to the The rest of the latest review is fixed in
|
There was a problem hiding this comment.
Reviewed the full base...head diff at this head - mx_execute outlogds/outstatus, the ms_runstp read fix, the regenerated all.sas and the new test coverage.
- xplatform/mx_execute.sas:206 (same block in all.sas): the SAS 9 branch only emits a NOTE that "&outlogds will be empty" and never creates the dataset, while the new outstatus at :211 is created with its documented columns. A caller that reads outlogds unconditionally therefore errors on SAS 9, and the word "empty" misdescribes a dataset that does not exist. Either create a zero-row dataset with the documented column (line) so both new outputs behave alike, or say "not created on SAS 9" in the NOTE and the @PARAM.
- xplatform/mx_execute.sas:76: the default debug changes from the string "log" to 131, and _debug is derived from it at :164 for every platform, so the change also alters the debug value handed to Viya job flows, not just the SASjs trigger URL. That is a user-visible default change (the header itself tells callers to pass debug= explicitly). The commit subject only claims outlogds forwarding - give it a feat! type or a BREAKING CHANGE footer so the release carries it.
- The new log coverage only proves that one known early line reaches outlogds; a regression that truncated the captured log would still pass. Assert on the volume of captured lines, or on a line the child emits late, so the read in ms_runstp is actually pinned.
No blocking issues.
Comments and @PARAM text should say what the code does, not what it used to do: the missing-INPUT note in ms_runstp, the history of the debug default, and the comparison with the removed work.results table.
The SAS 9 branch builds its outstatus row from assignments alone. A data step that reads nothing does write one row implicitly, but the intent is not visible and it is the only branch without an explicit write, so state it.
There was a problem hiding this comment.
Reviewed the full base...head diff: marginal regeneration in all.sas, xplatform/mx_execute.sas, server/ms_runstp.sas (input; added before line=_infile_; - correct, the old step could not advance), and the new tests.
- xplatform/mx_execute.sas:200 - the SAS 9 branch only writes a NOTE that outlogds "will be empty"; no dataset is created at all. A caller that follows the documented contract and runs
set &outlogdsafter mx_execute fails with "dataset does not exist" rather than seeing an empty table. Either create a zero-row dataset with the line column, or document that outlogds is not created on SAS 9. - xplatform/mx_execute.sas:69 - debug default changes from log to 131. On SASjs Server debug makes the server append the child log to the response, so the content every default-mode caller gets in outref/_webout changes, not just callers that ask for outlogds. Confirm that is intended and call it out as a behaviour change in the release notes.
- xplatform/mx_execute.sas:359 - prxchange returns the input string unchanged when the pattern does not match, so a line that contains "MSG" in any other shape (numeric value, no quotes, escaped quotes inside the message) sets errmsg to the whole line or to a garbled prefix of it, instead of the message. Gate with prxmatch first, or only assign when a match is found.
No blocking issues.
…g volume - SAS 9 created no outlogds at all, only a NOTE, so a caller following the documented contract failed with "dataset does not exist" while outstatus was always created. The dataset is now created with no rows; - prxchange returns its input unchanged when the pattern does not match, so a line containing MSG in another shape set errmsg to the whole line. Guarded with prxmatch; - Test 3 asserted only that one early line was present, which a truncated log would also satisfy. It now also pins the volume of captured lines. Refs #476
There was a problem hiding this comment.
Reviewed the full base...head diff: xplatform/mx_execute.sas, server/ms_runstp.sas, tests/testinit.sas, tests/x-platform/mx_execute.test.sas (all.sas is generated and not reviewed line by line). The new outlogds/outstatus outputs, the missing input; fix in ms_runstp.sas and the unique-name flow table all read correctly. Four points below.
-
xplatform/mx_execute.sas:290-300 (Viya outlogds copy):
do while(not eof); input; output; end;runs one iteration past the last record. The INPUT that hits end-of-file leaveslineat its previous value (DATA step variables are retained) andoutputwrites it again, so the captured log ends with its final line duplicated. Usedo until(eof); input; if not eof then output; end;. -
tests/x-platform/mx_execute.test.sas:118 (Test 3 counting loop):
do until(eof); set work.childlog end=eof; n+1; end;executes its body once even when the dataset has zero observations, because UNTIL is evaluated at the bottom of the loop. The SAS 9 path deliberately creates exactly that empty dataset, so n is 1 and the ifc(n=0,'PASS','FAIL') assertion at :128 fails on SAS 9 instead of passing. Guard the increment (do while(not eof); set ... end=eof; if not eof then n+1; end;) or read nobs. -
xplatform/mx_execute.sas:69: the default changed from debug=log to debug=131. Per the new docstring, on SASjs Server the log is only returned because the server appends it to the response in debug mode, so every existing %mx_execute call now carries a materially larger response and runs with debug logging, under a
feat:subject. Either keep the previous default and require an explicit debug= for log capture, or flag the change as breaking in the subject/PR description. -
xplatform/mx_execute.sas:34-38: the outstatus docstring promises an ERRMSG column, but the Viya branch sets errmsg='' unconditionally - mv_jobflow's output table (STATE, URI, TIMESTAMP, JOBPARAMS, FLOW_ID, _PROGRAM) carries no message column. A Viya job in state failed therefore reports no reason. Say so in the docstring; it currently reads as though the reason is always carried.
4 findings above for review.
The ilist holds variable names to check scoping for, so expanding the macro variable put its contents (a list of function names) into the list instead of the name itself.
… platform - the counting loop was a do-until, which runs its body once over an empty dataset, so the SAS 9 empty log counted as one line and the assertion failed there instead of passing. The count now comes from the descriptor; - outstatus documented ERRMSG as always carried, but only the SASjs Server branch can populate it - the Viya job flow has a state and no message.
|
Working through the four points; two fixes in 1. The Viya log loop does not duplicate the last line. With do while(not eof);
input;
output;
end;the The genuine edge case is an empty log file, where the body runs once with nothing read and writes one blank row. That is harmless for a log, and the alternative that removes it also removes real rows, so I left it. 2. Test 3 counting - agreed, fixed. A dsid=open('work.childlog');
n=attrn(dsid,'NOBS');
rc=close(dsid);3. 4. ERRMSG on Viya - agreed, fixed. The docstring now says ERRMSG is only populated on SASjs Server, from the abort block; the Viya job flow carries a state and no message, and SAS 9 gives neither. |
|
🎉 This PR is included in version 6.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
There was a problem hiding this comment.
Reviewed the full diff: mx_execute outlogds/outstatus on SAS 9, Viya and SASjs Server, ms_runstp log capture, the extended x-platform test suite, and the regenerated all.sas. CI green on this head.
- xplatform/mx_execute.sas:297 (Viya outlogds step):
input;populates only the input buffer, not the declaredlinevariable, so the log dataset gets the right row count with LINE missing on every row. Assign the buffer the way ms_runstp.sas does in this same PR: addline=_infile_;afterinput;(or useinput line;). - base/mp_assertscope.sas:84, and the same line in all.sas:
%upcase(&_SASJS_FUNCTIONS SYS_PROCHTTP_STATUS_CODEbecame%upcase(_SASJS_FUNCTIONS ..., dropping the macro-variable reference, so the literal token joins the ignore list and the variable's value no longer does. It is unrelated to this PR and silently changes what mp_init/mp_assertscope exclude from their scope checks - restore it, or split it out with a reason. - xplatform/mx_execute.sas:70: the default
debug=logbecomesdebug=131. On SASjs Server the server only appends the child log in debug mode, so every caller who never asked for a log now gets it in the response and payloads change under existing code. State that default change as a behaviour change in the PR body (the test that used to pindebug=lognow silently runs on the new default) so the maintainer can judge compatibility.
3 findings above for review.
…ds step (#477) Follow-up to the first finding in the post-merge review of #476. The Viya `outlogds` loop reads each job-log record with `input;` but never copies the buffer into the declared `line` variable, so `outlogds` comes back with the right number of rows and `LINE` missing on every one of them. The dataset looked populated while carrying no log text. This assigns `line=_infile_;` straight after `input;`, the same way `ms_runstp.sas` reads the chopped log in #476 (and the `putlog` step a few lines above already relies on `_infile_`). - `sasjs lint`: exit 0, no errors or warnings in `xplatform/mx_execute.sas`. - The Viya branch is code-review only - there is no Viya session here to run `tests/x-platform/mx_execute.test.sas` against, so Test 3 has not been re-executed on Viya. The SASjs Server path is untouched by this change. - `all.sas` is generated by the pipeline; not edited here. --------- Co-authored-by: dc <[email protected]> Co-authored-by: github-actions <[email protected]>
Three related gaps in
mx_execute, all found while making a test suite portable across SAS 9 / Viya / SASjs Server.1. The child's log could not be kept -
outlogds=mx_executeexposesoutlibandoutrefso a caller can capture what the child returned, but no way to keep the child's log, even though every platform that can return one already has it in hand inside the macro.%mv_jobflow(..., outref=&fref1 ...)already collects the job log and the macro prints it from&fref1; whenoutlogdsis set those lines are also written to the dataset (one column,line).%ms_testservice(..., outlogds=). The server appends the child's log to the response after the log separator andms_testservicediscards it unless asked, so withdebug=log(the default) the log was unreachable.proc stpreturns no child log. Documented in the header.2. The Viya branch left a fixed-name table in the caller's WORK
work.resultsis an internal detail of the job flow, but a predictable name that outlives the call reads like an output - and callers started depending on it. It is now%mf_getuniquename(prefix=mx_execute_)and is deleted before the macro returns.3. No supported way to tell whether the child completed -
outstatus=Removing
work.resultsremoves the only way a caller could see that a child was cancelled, so this adds the supported equivalent:outstatus=writes one row per program withSTATE,URI,ERRMSG,PLATFORM.stateandurifrom the job flow, written before the internal table is dropped.statederived from the response - asasjsAbortblock meanscanceled- with the abort message inERRMSG. A private response fileref is used (and cleared) when the caller asked only for the status.unknown, with a note inERRMSG;proc stpreturns no job status.All defaults keep existing callers unchanged.
Tests
tests/x-platform/mx_execute.test.sas- extended rather than adding a platform-specific file, sincemx_createwebservicebuilds the child wherever the test runs:outlogdsthe child's log is captured - asserted against the service's own%put- skipped on SAS 9.state=completed, and no fixed-name table is left in WORK (assertswork.resultsabsent).state=canceledwith its message, skipped on SAS 9.Tests 3 and 5 use the platform guard inside a macro, so no
%ifsits in open code.Verification
sasjs lint: exit 0, no errors, no warnings in either changed file.sasjs compile -t server: clean.sasjs cbd -t server(or a Viya target) first. The Viya branch and Test 5 on Viya are therefore code-review only in this PR.