diff --git a/sasjs-tests/src/components/TestCard.ts b/sasjs-tests/src/components/TestCard.ts index 9998ae3..65b1965 100644 --- a/sasjs-tests/src/components/TestCard.ts +++ b/sasjs-tests/src/components/TestCard.ts @@ -72,7 +72,7 @@ export class TestCard extends HTMLElement { ? `
Error: -
${(error as Error).message || String(error)}
+
${formatError(error)}
` : '' @@ -110,4 +110,35 @@ export class TestCard extends HTMLElement { } } +const escapeHtml = (s: string) => + s.replace(/&/g, '&').replace(//g, '>') + +const formatError = (err: unknown): string => { + if (err == null) return '' + if (typeof err === 'string') return escapeHtml(err) + + const anyErr = err as any + // Adapter ErrorResponse: { error: { message, details, raw } } + const nestedMsg = anyErr?.error?.message + const directMsg = anyErr?.message + const msg = directMsg || nestedMsg + + if (msg) { + const details = anyErr?.error?.details ?? anyErr?.details + const detailsStr = + details && typeof details === 'object' + ? `\n${JSON.stringify(details, null, 2)}` + : details + ? `\n${details}` + : '' + return escapeHtml(`${msg}${detailsStr}`) + } + + try { + return escapeHtml(JSON.stringify(err, null, 2)) + } catch { + return escapeHtml(String(err)) + } +} + customElements.define('test-card', TestCard) diff --git a/sasjs-tests/src/testSuites/Compute.ts b/sasjs-tests/src/testSuites/Compute.ts index 81b4cec..1e97278 100644 --- a/sasjs-tests/src/testSuites/Compute.ts +++ b/sasjs-tests/src/testSuites/Compute.ts @@ -11,7 +11,7 @@ export const computeTests = (adapter: SASjs, appLoc: string): TestSuite => ({ title: 'Compute API request', description: 'Should run the request with compute API approach', test: async () => { - return await adapter.request('common/sendArr', stringData) + return await adapter.request('services/common/sendArr', stringData) }, assertion: (response: any) => { return response.table1[0][0] === stringData.table1[0].col1 @@ -25,7 +25,11 @@ export const computeTests = (adapter: SASjs, appLoc: string): TestSuite => ({ useComputeApi: false } - return await adapter.request('common/sendArr', stringData, config) + return await adapter.request( + 'services/common/sendArr', + stringData, + config + ) }, assertion: (response: any) => { return response.table1[0][0] === stringData.table1[0].col1 @@ -36,7 +40,10 @@ export const computeTests = (adapter: SASjs, appLoc: string): TestSuite => ({ description: 'Should start a compute job and return the session', test: () => { const data: any = { table1: [{ col1: 'first col value' }] } - return adapter.startComputeJob(`${appLoc}/common/sendArr`, data) + return adapter.startComputeJob( + `${appLoc}/services/common/sendArr`, + data + ) }, assertion: (res: any) => { const expectedProperties = ['id', 'applicationName', 'attributes'] @@ -49,7 +56,7 @@ export const computeTests = (adapter: SASjs, appLoc: string): TestSuite => ({ test: () => { const data: any = { table1: [{ col1: 'first col value' }] } return adapter.startComputeJob( - `${appLoc}/common/sendArr`, + `${appLoc}/services/common/sendArr`, data, {}, undefined, diff --git a/src/SASViyaApiClient.ts b/src/SASViyaApiClient.ts index 9ca88f6..e5b75b6 100644 --- a/src/SASViyaApiClient.ts +++ b/src/SASViyaApiClient.ts @@ -1031,11 +1031,17 @@ export class SASViyaApiClient { jobArguments[`_webin_name${index + 1}`] = fileInfo.tableName }) + // Viya JES requires arguments to be Map; coerce booleans/numbers. + const stringifiedArguments: { [key: string]: string } = {} + for (const k of Object.keys(jobArguments)) { + stringifiedArguments[k] = String(jobArguments[k]) + } + const postJobRequestBody = { name: `exec-${jobName}`, description: 'Powered by SASjs', jobDefinition, - arguments: jobArguments + arguments: stringifiedArguments } const { result: postedJob } = await this.requestClient.post(