Skip to content

Commit 95d1807

Browse files
committed
MLE-24763 Including server response body in error message
Fixed test that was do an equals comparison on the error message, and it no longer times out now.
1 parent f4d3670 commit 95d1807

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

lib/responder.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,9 @@ function isResponseStatusOkay(response) {
10391039
((typeof contentType === 'string' || contentType instanceof String) &&
10401040
/^application\/([^+]+\+)?json(\s*;.*)?$/.test(contentType)) ?
10411041
mlutil.parseJSON(bodyMsg) : bodyMsg;
1042+
1043+
// Enhance error message with response body details for better debugging
1044+
clientError.message = `${clientError.message}; server response: ${bodyMsg}`;
10421045
}
10431046
operation.errorListener(clientError);
10441047
}));

test-basic/validateDoc-test.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,27 @@ describe('optic-update validateDoc tests', function () {
184184
});
185185

186186
it('test validateDoc with 1 invalid doc and no "onError" defined, should return nothing in 11.1-, or throw an exception on 11.2+', function (done) {
187-
try {
188-
const plan = op.fromDocDescriptors([{ uri: '/test/optic/validateDoc/toValidate1.xml' }])
189-
.joinDocCols(null, op.col('uri'))
190-
.validateDoc('doc', { kind: 'xmlSchema' });
191-
db.rows.query(plan, options).then(res => {
192-
try {
193-
(res === undefined).should.equal(true);
194-
done();
195-
} catch (e) {
196-
done(e);
197-
}
198-
}).catch(e => {
199-
e.message.should.equal('query rows: response with invalid 500 status with path: /v1/rows/update');
187+
const plan = op.fromDocDescriptors([{ uri: '/test/optic/validateDoc/toValidate1.xml' }])
188+
.joinDocCols(null, op.col('uri'))
189+
.validateDoc('doc', { kind: 'xmlSchema' });
190+
191+
db.rows.query(plan, options).then(res => {
192+
// If we get here, the query succeeded (expected in 11.1-)
193+
try {
194+
(res === undefined).should.equal(true);
200195
done();
201-
});
202-
} catch (e) {
203-
done(e);
204-
}
196+
} catch (e) {
197+
done(e);
198+
}
199+
}).catch(e => {
200+
// If we get here, the query failed (expected in 11.2+)
201+
try {
202+
e.message.should.containEql('query rows: response with invalid 500 status with path: /v1/rows/update');
203+
done();
204+
} catch (assertionError) {
205+
done(assertionError);
206+
}
207+
});
205208
});
206209

207210
// Skip this test until the 'onError' function is available in plan-builder.js

0 commit comments

Comments
 (0)