fix(loader): abort when a post edit hook routes to an unregistered table
Build / Build-and-ng-test (pull_request) Successful in 5m48s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m13s
Build / Build-and-test-development (pull_request) Successful in 25m15s

A POST_EDIT_HOOK may re-point a changeset at a different table - that is what
lets an empty mirror stand in for a real one. Nothing checked the result, so a
hook pointing at a table with no MPE_TABLES row produced a changeset that could
not be reviewed: mpe_checkrestore resolves the audit table from that row, and
with none found its `select count(*) into: chk from &audtab` collapses to
`from where ...` - ERROR 22-322, syscc=1012, and the approval screen aborts
with a syntax error rather than an explanation.

Validate the target immediately after the hook, while the submitter is still
watching, and fail with a message naming the table and the reason. The target
table must be registered in MPE_TABLES; a hook may only route to a registered
table.

Verified on the test estate against the deployed stagedata service:
- target unregistered -> job cancels with
  'ERROR: target table DCHOOK.ORDERS is not registered in VIYA0846.mpe_tables -
  a post edit hook may only route a changeset to a registered table'
  (MPE_LOADFAIL STATUS 'FAILED - TARGET NOT REGISTERED')
- target registered -> the same submit returns STATUS SUCCESS
This commit is contained in:
dc committed 2026-09-24 15:45:24 +00:00
1 parent f1734a2de0
commit 171974bd41
1 file changed
+27
+27
View File
@@ -462,6 +462,33 @@ run;
%return;
%end;
/* The post edit hook may have re-pointed the changeset at a different table -
* that is what lets an empty mirror stand in for a real one. The target must
* itself be registered in MPE_TABLES: the approval screen resolves the table's
* audit settings from that row, and a changeset whose base table has no row
* cannot be reviewed. Fail here, while the submitter is still watching. */
%local target_chk;
proc sql noprint;
select count(*) into: target_chk
from &mpelib..mpe_tables
where tx_from le &now and &now lt tx_to
and upcase(libref)="%upcase(&libref)"
and upcase(dsn)="%upcase(&ds)";
%if &target_chk=0 %then %do;
%let msg=%str(ERR)OR: target table &libref..&ds is not registered in%trim(
) &mpelib..mpe_tables - a post edit hook may only route a changeset to a%trim(
) registered table;
%mpe_loadfail(
status=FAILED - TARGET NOT REGISTERED
,now=&now
,mperef=&mperef
,reason_txt=%quote(&msg)
,dc_dttmtfmt=&dc_dttmtfmt.
)
%mp_abort(msg=&msg,mac=mpe_loader.sas);
%return;
%end;
/**
* send to approve process