sasjs / adapter

An adapter for bidirectional SAS® <-> Javascript communication

Home Page:https://adapter.sasjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The input provided for this request is not valid for this endpoint.

allanbowe opened this issue · comments

Expected behaviour

Adapter should make requests on recent versions of Viya 4

Current behaviour

When making requests using the Compute API approach, the following response is received (seen in both a web context, and using the CLI):

{
  version: 2,
  httpStatusCode: 400,
  errorCode: 5036,
  message: 'The input provided for this request is not valid for this endpoint. ',
  details: [
    'path: /compute/sessions/0c693397-7703-4c4a-966b-bc37161fb76d-ses0000/jobs',
    'correlator: cb844ce3-89cd-4464-b364-85b3b8f7938c'
  ],
  remediation: 'Check to make sure the request made to the server is a valid request. Contact your system administrator to determine if the request made from your application is formatted correctly.'
}

Environment info

Client tech stack: VanillaJS, NodeJS
Server type: SASVIYA
Use Compute Api (relevant only on VIYA): true

Here is the verbose log from the CLI:

ℹ HTTP Request (first 50 lines):                                                                                                                             18:14:27
POST /compute/sessions/ca3f4bdf-3cf8-48b5-91fb-f9f11999789c-ses0000/jobs HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsIREDACTED
User-Agent: axios/0.27.2
Content-Length: 1162
Host: extviya4.emea.sas.com
Connection: close

{
  name: 'long',
  description: 'Powered by SASjs',
  code: [
    '* Job Variables start;',
    '',
    '',
    '* Job Variables end;',
    '* SAS Macros start;',
    '',
    '',
    '',
    '',
    '%macro example(msg);',
    '',
    '  %let testvar=%sysfunc(ranuni(0));',
    '',
    '  data work.example;',
    "    msg=symget('msg');",
    '    putlog msg=;',
    '  run;',
    '',
    '%mend example ;',
    '',
    '* SAS Macros end;',
    '* SAS Includes start;',
    '',
    '* SAS Includes end;',
    '* Binary Files start;',
    '',
    '* Binary Files end;',
    '',
    '    ',
    '* JobInit start;',
    '',
    '',
    '%example(Job Init is executing!)',
    '',
    '%let mylib=WORK;',
    '* JobInit end;',
    '* Job start;',
    '/**',
    '  @file',
    '  @brief <Your brief here>',
    '  <h4> SAS Macros </h4>',
    '**/',
    'data work.bigdataset;',
    '  do x=1 to 1e7;',
    '    y=ranuni(0);',
    "    z=repeat('sobig',5000);",
    "    zz=repeat('andme',5000);",
    '  end;',
    'run;',
    '',
    '* Job end;',
    '* JobTerm start;',
    '',
    '',
    '%example(Job Term is executing!)',
    '* JobTerm end;'
  ],
  variables: {
    SYS_JES_JOB_URI: '',
    _program: '/Viyademo08 Group Folder/4GL/proj/yurshk/jobs/long/long',
    _DEBUG: 131
  },
  arguments: {
    _contextName: 'SAS Job Execution compute context',
    _OMITJSONLISTING: true,
    _OMITJSONLOG: true,
    _OMITSESSIONRESULTS: false,
    _OMITTEXTLISTING: true,
    _OMITTEXTLOG: false
  }
}

HTTP Response Code: 400

HTTP Response (first 50 lines):
Date: Fri, 01 Sep 2023 15:14:27 GMT
Content-Type: application/vnd.sas.error+json;charset=utf-8;version=2
Content-Length: 470
Connection: close
Set-Cookie: sas-ingress-nginx=9a59cdfa1a238157REDACTED; Path=/compute/; Secure; HttpOnly; SameSite=Lax
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Security-Policy: default-src 'self'; object-src 'none'; frame-ancestors 'self'; form-action 'self';
Expires: 0
Pragma: no-cache
Sas-Service-Response-Flag: true
Vary: Origin
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Strict-Transport-Security: max-age=63072000; includeSubDomains

{
  version: 2,
  httpStatusCode: 400,
  errorCode: 5036,
  message: 'The input provided for this request is not valid for this endpoint. ',
  details: [
    'path: /compute/sessions/ca3f4bdf-3cf8-48b5-91fb-f9f11999789c-ses0000/jobs',
    'correlator: d03057f5-3c73-4a2c-b171-af28f8367024'
  ],
  remediation: 'Check to make sure the request made to the server is a valid request. Contact your system administrator to determine if the request made from your application is formatted correctly.'
}

The fix for this was to simply remove the arguments object from the request payload when useComputeApi: true