Skip to content

fix(server): honor the debug parameter in the STP trigger macros - #458

Merged
allanbowe merged 2 commits into
mainfrom
fix/forward-debug-param
Oct 5, 2026
Merged

allanbowe merged 2 commits into
mainfrom
fix/forward-debug-param

Conversation

@sasjs-dev

@sasjs-dev sasjs-dev Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Fixes the one surviving review finding from #382, and closes it as superseded.

What happened to #382

Its macro, ms_triggerstp, landed on main via #442 in finished form - together with the test file the reviewer asked for. I verified each of the reviewer's 7 findings against main's version:

Finding Status on main
1. &boundary never defined fixed - %let boundary=%mf_getuniquename();
2. &outref never defined fixed - %let outref=%mf_getuniquefileref();
3. orphaned DATA step (data work.%mf_getuniquename(); ... input with no run;) fixed - replaced with libname &libref JSON parsing
4. &outlogds undefined fixed - the parameter is gone entirely
6. @brief said /code/trigger, URL used /stp/trigger fixed - both say /SASjsApi/stp/trigger
7. outds declared but never written fixed - proc append base=&outds
5. debug= accepted but ignored, URL hardcodes _debug=131 still present on main

Finding 5 is what this PR fixes - in both macros that have it.

The fix

ms_runstp and ms_triggerstp both take debug=, documented as the _debug value to send, and both hardcoded _debug=131 in the URL. ms_testservice forwards debug=&debug to ms_runstp, so its callers were silently ignored too:

ms_runstp        url now uses _debug=&debug
ms_triggerstp    url now uses _debug=&debug
ms_testservice   signature default 0 -> 131, matching its documented default

Why the default stays 131 and existing callers see no change: the server appends the session log to the response only when _debug is 131 or above (isDebugOn in sasjs/server), and ms_runstp's outlogds chopping depends on the log separator being present. So 131 is load-bearing for the documented outlogds contract, not an arbitrary constant.

The one caller passing a non-default value - ms_testservice's own test, with debug=log - is corrected to use the default. The server validates _debug as a number (Joi.number() in triggerProgramValidation), so log was working only because the parameter was ignored; the macro's own doc header already claimed 131 as the default while its signature said 0.

Also picked up by the regeneration

all.sas is CI-generated, so build.py was rerun. That surfaced a pre-existing drift: #456 changed proc sql to proc sql noprint in mp_jsonout.sas, which is embedded into mm_createwebservice.sas and ms_createwebservice.sas inside their /* WEBOUT BEGIN */ blocks - and the regeneration had not been run for those two files. The diff includes that propagation.

Verified

  • sasjs lint exit 0, 0 errors; warnings identical to main (bisected: same 3 mp_abort header warnings on a clean main checkout)
  • build.py rerun; all.sas carries the fix at both URL sites

ms_runstp and ms_triggerstp both take a debug= parameter, documented as the
_debug value to send, and both hardcoded _debug=131 in the request URL - the
parameter was accepted and ignored. ms_testservice forwards debug=&debug to
ms_runstp, so its callers have been silently ignored too.

    ms_runstp       url now uses &_debug=&debug
    ms_triggerstp   url now uses &_debug=&debug
    ms_testservice   signature default 0 -> 131, matching its documented
                     default and the value the response-log parsing depends on

The server appends the session log to the response only when _debug is 131 or
above, and ms_runstp's outlogds chopping depends on that log separator, so 131
remains the default everywhere and existing callers see no change.

The one caller that passed a non-default value - ms_testservice's own test,
with debug=log - is corrected to rely on the default. The server validates
_debug as a number, so 'log' was relying on being ignored, and its
documentation already stated 131 as the default while the signature said 0.

all.sas is regenerated (build.py). The regeneration also picks up the proc sql
noprint change from #456, which had not been propagated into the embedded
webout blocks of mm_createwebservice and ms_createwebservice.

Verified: sasjs lint exit 0 with 0 errors (warnings unchanged from main).
@allanbowe
allanbowe merged commit b13a83f into main Oct 5, 2026
2 checks passed
@allanbowe
allanbowe deleted the fix/forward-debug-param branch October 5, 2026 01:12
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 5.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant