Skip to content

feat: triggerstp Stored Program - #382

Draft
allanbowe wants to merge 2 commits into
mainfrom
triggerstp
Draft

feat: triggerstp Stored Program#382
allanbowe wants to merge 2 commits into
mainfrom
triggerstp

Conversation

@allanbowe

Copy link
Copy Markdown
Member

WIP

@4gl-reviewer

4gl-reviewer Bot commented Aug 14, 2026

Copy link
Copy Markdown

Test Coverage Report

Overall coverage: 114/170 macros (67%)

Command run: npx @sasjs/cli c (target: server)

PR-Changed Macros

Macro File Status
ms_triggerstp server/ms_triggerstp.sas ❌ Not covered

Notes

  • ms_triggerstp.sas is a newly added macro with no corresponding test file (e.g. tests/serveronly/ms_triggerstp.test.sas).
  • The sasjs/core convention is that each macro in server/ has a matching tests/serveronly/*.test.sas file. Sibling macro ms_runstp.sas has ms_runstp.test.sas; ms_triggerstp does not.
  • Coverage remained at 67% (114/170) — the new macro added to the denominator but not to covered macros.
  • all.sas is a generated concatenation file and is not individually tested.

Generated by Hermes Agent (GitHub App)

@4gl-reviewer 4gl-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hermes Agent Code Review

Verdict: ❌ Request Changes — The new ms_triggerstp macro contains multiple undefined macro variable references and an incomplete DATA step that will cause runtime failures. The macro appears to be an in-progress adaptation of ms_runstp.sas with several parameters and initializations left out. Given this is a DRAFT PR (body: "WIP"), these findings are expected, but they must be resolved before merge.

Pre-Review Checks

  • Mergeable: false (mergeable_state: dirty) — the PR has merge conflicts with main.
  • Check runs: 0 check runs found for the head SHA.
  • Coverage: npx @sasjs/cli c ran successfully — 114/170 macros covered (67%). ms_triggerstp is not covered (no test file exists).

Critical Issues

  1. &boundary is never defined — The %local statement (line 52) omits boundary, and there is no %let boundary=%mf_getuniquename();. All multipart form-data delimiters (--&boundary on lines 80, 117, 129, 136) resolve to empty strings, producing a malformed multipart body. The sibling macro ms_runstp.sas (line 59) correctly initializes it.

  2. &outref is never defined — Used on lines 154, 157, and 168 but never declared as a parameter or %local. ms_runstp declares outref=outweb as a parameter. Here, proc http out=&outref will fail because &outref resolves to empty.

  3. &outlogds is never defined — Used on lines 183 and 196 but never declared. The %if &outlogds ne _null_ condition on line 183 references an undefined macro variable. ms_runstp declares outlogds=_null_ as a parameter.

  4. Incomplete / orphaned DATA step (lines 179–181)data work.%mf_getuniquename(); starts a DATA step with infile and a bare input statement (no input specification, no run;). When outlogds is not provided and mdebug=0 (the defaults), the %if block on line 183 is skipped, leaving an unclosed DATA step — a syntax error. Even when the %if block executes, the data &outlogds; ... run; (lines 196–203) closes a different DATA step; the original one on line 179 is never properly terminated.

Major Issues

  1. outds parameter declared but never used — The outds=work.ms_triggerstp parameter (line 49) is documented as the output dataset to contain the sessionId, but no code in the macro body writes to it. The doc header (lines 30–36) describes the expected output format, but the implementation is missing.

  2. debug parameter accepted but ignored — The URL on line 159 hardcodes _debug=131 instead of using &debug. The debug= parameter (line 46) has no effect on the request.

  3. Endpoint path inconsistency — The @brief doc (line 3) references /SASjsApi/code/trigger, but the actual URL (line 158) uses /SASjsApi/stp/trigger. These should be consistent; verify which endpoint is correct for the SASjs Server API.

Minor Issues

  1. No test file — There is no tests/serveronly/ms_triggerstp.test.sas. Every other server/ms_*.sas macro that ships has a corresponding test (e.g. ms_runstp.test.sas, ms_testservice.test.sas). A test should be added following the pattern in ms_runstp.test.sas.

  2. all.sas correctly updated — The concatenated all.sas file includes the new macro content matching server/ms_triggerstp.sas. No issue here.

Summary

This macro is a near-copy of ms_runstp.sas adapted for the /SASjsApi/stp/trigger endpoint, but the adaptation is incomplete. At minimum, the following must be added/fixed before this is functional:

  • Add %let boundary=%mf_getuniquename(); and include boundary in %local
  • Declare outref and outlogds as parameters (or %local variables)
  • Complete the DATA step that parses the response and writes the sessionId to &outds
  • Use &debug instead of hardcoded 131 in the URL
  • Reconcile the endpoint path in the doc header vs. the URL
  • Add a test file
  • Resolve merge conflicts with main

Reviewed by Hermes Agent (GitHub App)

Comment thread server/ms_triggerstp.sas
,outds=work.ms_triggerstp
,mdebug=0
);
%local dbg mainref authref;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: &boundary is never defined.

The %local statement omits boundary, and there is no %let boundary=%mf_getuniquename();. Compare with ms_runstp.sas line 56-59:

%local dbg mainref authref boundary;
%let boundary=%mf_getuniquename();

Without this, all --&boundary references (lines 80, 117, 129, 136) resolve to empty strings, producing a malformed multipart/form-data body. The API request will fail.

Comment thread server/ms_triggerstp.sas

%local resp_path;
%let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
filename &outref "&resp_path" lrecl=32767;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: &outref is undefined.

&outref is used here and on lines 157, 168 but is never declared as a parameter or %local variable. In ms_runstp.sas, outref=outweb is a declared macro parameter. Here it will resolve to empty, causing filename &outref and proc http out=&outref to fail.

The macro declares outds= instead — but outds is never used in the body (see line 49).

Comment thread server/ms_triggerstp.sas
/* reset options */
options &optval;

data work.%mf_getuniquename();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: Incomplete / orphaned DATA step.

This data work.%mf_getuniquename(); step has:

  • infile "&resp_path"; (line 180)
  • input (line 181 — bare, no specification)
  • No run; statement

When outlogds is undefined (default) and mdebug=0 (default), the %if block on line 183 is skipped entirely, leaving this DATA step unclosed — a SAS syntax error.

This step appears intended to parse the API response and write the sessionId to &outds, but the implementation is missing. The outds parameter is declared (line 49) and documented (lines 30-36) but never populated.

Comment thread server/ms_triggerstp.sas
infile "&resp_path";
input

%if &outlogds ne _null_ or &mdebug=1 %then %do;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: &outlogds is undefined.

&outlogds is used here and on line 196 but is never declared as a parameter or %local variable. In ms_runstp.sas, outlogds=_null_ is a declared parameter. The %if &outlogds ne _null_ condition references an undefined variable (resolves to _null_ by SAS convention, so the block is skipped — but this is accidental, not intentional).

Comment thread server/ms_triggerstp.sas
/* prepare request*/
proc http method='POST' headerin=&authref in=&mainref out=&outref
url="&_sasjs_apiserverurl/SASjsApi/stp/trigger?%trim(
)_program=&pgm%str(&)_debug=131";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Major: debug parameter is ignored.

The URL hardcodes _debug=131 instead of using &debug. The debug= parameter (line 46) is accepted but has no effect. Should be:

url="&_sasjs_apiserverurl/SASjsApi/stp/trigger?%trim(
  )_program=&pgm%str(&)_debug=&debug";

Comment thread server/ms_triggerstp.sas
@@ -0,0 +1,215 @@
/**
@file
@brief Triggers a SASjs Server STP using the /SASjsApi/code/trigger endpoint

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Major: Endpoint path inconsistency.

The @brief says /SASjsApi/code/trigger but the actual URL on line 158 uses /SASjsApi/stp/trigger. Please reconcile — verify which is the correct SASjs Server API endpoint and update the doc header to match.

Comment thread server/ms_triggerstp.sas
,debug=131
,inputparams=_null_
,inputfiles=_null_
,outds=work.ms_triggerstp

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Major: outds parameter declared but never used.

The outds=work.ms_triggerstp parameter is documented (lines 30-36) as the output dataset to contain the sessionId, but no code in the macro body writes to it. The response-parsing DATA step (line 179) is incomplete and writes to a random mf_getuniquename() dataset instead.

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