Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f3958cb
fix(search): handle repeated query params and non-string _search JSON
jmandel Dec 6, 2026
7b6c0f1
fix(batch-validate): return 405 for GET and 400 for malformed POST bo…
jmandel Dec 6, 2026
16b959f
fix(worker): return HTTP 422 instead of 500 for ValueSet.compose.lock…
jmandel Dec 6, 2026
8f801e2
fix(parameters): reject multi-value[x] and mixed choice-type paramete…
jmandel Dec 6, 2026
f57c19a
fix(omop): throw typed 422 too-costly Issue from iterator()/nextConte…
jmandel Dec 6, 2026
bdb64e1
fix(parsers): preserve UTF-16 surrogate pairs in VCL and SNOMED SCG e…
jmandel Dec 6, 2026
f72a80e
fix(parameters): enforce 32-bit signed FHIR integer bounds with HTTP 400
jmandel Dec 6, 2026
eaf5ac0
fix(tx): return 400 FHIR JSON OperationOutcome on malformed JSON bodies
jmandel Dec 6, 2026
83d21ad
fix(translate,xversion): strip R4 equivalence on R5 responses and rej…
jmandel Dec 6, 2026
f298e3e
fix(lookup): omit empty description for displayless parent/child conc…
jmandel Dec 6, 2026
28c28ef
fix(expand): fix doubled cs.system() and non-standard example paramet…
jmandel Dec 6, 2026
189d2a9
fix(cs): support structural parent exists filter in FhirCodeSystemPro…
jmandel Dec 6, 2026
8af47ac
fix(lookup): pass null for missing version so system|version lookups …
jmandel Dec 6, 2026
2c6d496
fix(ecl): reject 4 malformed ECL 2.2 constructs (cardinality, history…
jmandel Dec 6, 2026
38ca357
fix(expand): include primaryResources in sessionless additionalResour…
jmandel Dec 6, 2026
84a3067
fix(expand): retain used-supplement parameter when offset >= total
jmandel Dec 6, 2026
e06be1c
fix(validate): unwrap ValueSet wrapper and call checkCanonicalStatusC…
jmandel Dec 6, 2026
d74ba51
fix(worker): avoid literal 'null' on versionless CS and deduplicate V…
jmandel Dec 6, 2026
cbc9cd7
fix(validate): avoid duplicating valid display choices on abstract=fa…
jmandel Dec 6, 2026
9733377
fix(i18n): unescape template '' before substituting parameters
jmandel Dec 6, 2026
3a3f5a9
fix(subsumes): reject non-Parameters JSON POST with 400 Wrong_type_fo…
jmandel Dec 6, 2026
c223dc9
fix(expand): deduplicate preferredForLanguage designation in listDisp…
jmandel Dec 6, 2026
87b4c54
fix(i18n): parse Accept-Language as Languages iterable in requestLang…
jmandel Dec 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions library/i18n/i18nsupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class I18nSupport {
return messageId; // Fallback to message ID if not found
}

// Substitute parameters {0}, {1}, etc.
return this._substituteParameters(message.trim(), parameters).replaceAll("''", "'");
// Unescape ICU '' in the template before substituting parameters so values starting with ' are preserved
return this._substituteParameters(message.trim().replaceAll("''", "'"), parameters);
}

_formatMessagePluralFromBundle(bundles, languages, messageId, count, parameters = []) {
Expand All @@ -166,8 +166,8 @@ class I18nSupport {
// Prepend count as parameter 0, shift other parameters
const allParameters = [count.toString(), ...parameters];

// Substitute parameters {0}, {1}, etc.
return this._substituteParameters(message, allParameters).replaceAll("''", "'");
// Unescape ICU '' in the template before substituting parameters
return this._substituteParameters(message.replaceAll("''", "'"), allParameters);
}

/**
Expand Down Expand Up @@ -279,7 +279,7 @@ function englishMessage(messageId, parameters = []) {
if (!message) {
return messageId;
}
return I18nSupport.prototype._substituteParameters(message.trim(), parameters).replaceAll("''", "'");
return I18nSupport.prototype._substituteParameters(message.trim().replaceAll("''", "'"), parameters);
}

let shared = null;
Expand Down
61 changes: 61 additions & 0 deletions tests/tx/fix-accept-language-iterable.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Regression test: Accept-Language header parsing in requestLanguages() and
* TerminologyWorker.buildParameters() must return an iterable Languages instance
* rather than a single Language from LanguageDefinitions.parse().
*/

const request = require('supertest');
const { getTestApp, shutdownTestApp } = require('./setup');

const R5 = '/tx/r5';

describe('Accept-Language iterable handling in error responses', () => {
let app;

beforeAll(async () => {
app = await getTestApp();
}, 240000);

afterAll(async () => {
await shutdownTestApp();
});

test.each(['*', 'en-US', 'en-US,en;q=0.9', 'de;q=0.8,en;q=0.5'])(
'invalid parameter with Accept-Language: %s returns 400 (not 500 languages is not iterable)',
async (acceptLang) => {
const res = await request(app)
.post(`${R5}/ValueSet/$expand`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.set('Accept-Language', acceptLang)
.send({
resourceType: 'Parameters',
parameter: [
{ name: 'url', valueUri: 'http://hl7.org/fhir/ValueSet/administrative-gender' },
{ name: 'offset', valueInteger: 2147483648 }
]
});
expect(res.status).toBe(400);
expect(res.body.resourceType).toBe('OperationOutcome');
expect(res.body.issue[0].code).toBe('invalid');
}
);

test.each(['*', 'en-US,en;q=0.9'])(
'non-Parameters POST to $lookup with Accept-Language: %s returns 400 Wrong_type_for_resource_expected',
async (acceptLang) => {
const res = await request(app)
.post(`${R5}/CodeSystem/$lookup`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.set('Accept-Language', acceptLang)
.send({ resourceType: 'Bundle', id: 'wrong-rt' });
expect(res.status).toBe(400);
expect(res.body.resourceType).toBe('OperationOutcome');
const msgIds = (res.body.issue || []).flatMap(i => (i.extension || [])
.filter(e => e.url === 'http://hl7.org/fhir/StructureDefinition/operationoutcome-message-id')
.map(e => e.valueString));
expect(msgIds).toContain('Wrong_type_for_resource_expected');
}
);
});
62 changes: 62 additions & 0 deletions tests/tx/fix-iss01-search-params.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Regression test for ISS-01: search endpoints with repeated query params and non-string _search JSON.
*/

const request = require('supertest');
const { getTestApp, shutdownTestApp } = require('./setup');

const R5 = '/tx/r5';

describe('ISS-01: search endpoints handle repeated query params and non-string _search JSON', () => {
let app;

beforeAll(async () => {
app = await getTestApp();
}, 240000);

afterAll(async () => {
await shutdownTestApp();
});

test('GET /CodeSystem?status=active&status=draft returns 200 (AND-ed) instead of 500', async () => {
const res = await request(app).get(`${R5}/CodeSystem?status=active&status=draft`).set('Accept', 'application/fhir+json');
expect(res.status).toBe(200);
expect(res.body.resourceType).toBe('Bundle');
expect(res.body.total).toBe(0);
});

test('GET /ValueSet and /ConceptMap with repeated status return 200 instead of 500', async () => {
for (const rt of ['ValueSet', 'ConceptMap']) {
const res = await request(app).get(`${R5}/${rt}?status=active&status=draft&_count=1`).set('Accept', 'application/fhir+json');
expect(res.status).toBe(200);
expect(res.body.resourceType).toBe('Bundle');
}
});

test('POST /ConceptMap/_search with numeric JSON values returns 200 instead of 500', async () => {
const res = await request(app).post(`${R5}/ConceptMap/_search`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.send({ _count: 3, version: 4 });
expect(res.status).toBe(200);
expect(res.body.resourceType).toBe('Bundle');
});

test('POST /ConceptMap/_search with non-primitive object value returns 400 OperationOutcome', async () => {
const res = await request(app).post(`${R5}/ConceptMap/_search`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.send({ version: { bad: true } });
expect(res.status).toBe(400);
expect(res.body.resourceType).toBe('OperationOutcome');
expect(res.body.issue[0].code).toBe('invalid');
});

test('Bundle.link.url preserves repeated query params without comma-joining', async () => {
const res = await request(app).get(`${R5}/ValueSet?source=none&status=active&status=draft&_count=1`).set('Accept', 'application/fhir+json');
expect(res.status).toBe(200);
const selfUrl = res.body.link.find(l => l.relation === 'self').url;
expect(selfUrl).toContain('status=active&status=draft');
expect(selfUrl).not.toContain('active%2Cdraft');
});
});
55 changes: 55 additions & 0 deletions tests/tx/fix-iss02-batch-validate-get.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Regression test for ISS-02: GET /$batch-validate-code returns 405 and malformed POST returns 400.
*/

const request = require('supertest');
const { getTestApp, shutdownTestApp } = require('./setup');

const R5 = '/tx/r5';

describe('ISS-02: $batch-validate-code GET 405 and malformed POST body 400', () => {
let app;

beforeAll(async () => {
app = await getTestApp();
}, 240000);

afterAll(async () => {
await shutdownTestApp();
});

test.each(['ValueSet', 'CodeSystem'])('GET /%s/$batch-validate-code returns 405 with Allow: POST', async (rt) => {
const res = await request(app).get(`${R5}/${rt}/$batch-validate-code`).set('Accept', 'application/fhir+json');
expect(res.status).toBe(405);
expect(res.headers.allow).toBe('POST');
expect(res.body.resourceType).toBe('OperationOutcome');
});

test('POST /ValueSet/$batch-validate-code with non-Parameters body returns 400', async () => {
const res = await request(app).post(`${R5}/ValueSet/$batch-validate-code`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.send({ resourceType: 'Bundle', type: 'collection' });
expect(res.status).toBe(400);
expect(res.body.resourceType).toBe('OperationOutcome');
expect(res.body.issue[0].code).toBe('invalid');
});

test('GET /ValueSet/$batch-validate-code honors Accept: application/fhir+xml on 405', async () => {
const res = await request(app).get(`${R5}/ValueSet/$batch-validate-code`).set('Accept', 'application/fhir+xml');
expect(res.status).toBe(405);
expect(res.headers.allow).toBe('POST');
expect(res.headers['content-type']).toMatch(/xml/);
expect(res.text).toContain('<OperationOutcome');
});

test('POST /ValueSet/$batch-validate-code with non-Parameters validation entry returns 400', async () => {
const res = await request(app).post(`${R5}/ValueSet/$batch-validate-code`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.send({ resourceType: 'Parameters', parameter: [{ name: 'validation', valueString: 'bad' }] });
expect(res.status).toBe(400);
expect(res.body.resourceType).toBe('OperationOutcome');
expect(res.body.issue[0].code).toBe('invalid');
});
});
53 changes: 53 additions & 0 deletions tests/tx/fix-iss03-locked-date.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Regression test for ISS-03: ValueSet.compose.lockedDate returns HTTP 422 instead of 500.
*/

const request = require('supertest');
const { getTestApp, shutdownTestApp } = require('./setup');

const R5 = '/tx/r5';

describe('ISS-03: ValueSet.compose.lockedDate returns 422 business-rule', () => {
let app;

beforeAll(async () => {
app = await getTestApp();
}, 240000);

afterAll(async () => {
await shutdownTestApp();
});

const post = (op, parameter) =>
request(app).post(`${R5}/${op}`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.send({ resourceType: 'Parameters', parameter });

const lockedVs = {
resourceType: 'ValueSet',
url: 'http://example.org/vs-locked',
status: 'active',
compose: {
lockedDate: '2025-01-01',
include: [{ system: 'http://hl7.org/fhir/administrative-gender' }]
}
};

test('$expand rejects lockedDate with 422 business-rule', async () => {
const res = await post('ValueSet/$expand', [{ name: 'valueSet', resource: lockedVs }]);
expect(res.status).toBe(422);
expect(res.body.resourceType).toBe('OperationOutcome');
expect(res.body.issue[0].code).toBe('business-rule');
});

test('$compare rejects lockedDate with 422 business-rule', async () => {
const res = await post('ValueSet/$compare', [
{ name: 'thisValueSet', resource: lockedVs },
{ name: 'otherUrl', valueUri: 'http://hl7.org/fhir/ValueSet/administrative-gender' }
]);
expect(res.status).toBe(422);
expect(res.body.resourceType).toBe('OperationOutcome');
expect(res.body.issue[0].code).toBe('business-rule');
});
});
54 changes: 54 additions & 0 deletions tests/tx/fix-iss04-multi-value-param.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Regression test for ISS-04: multi-value[x] / mixed choice-type Parameters.parameter rejected with 400.
*/

const request = require('supertest');
const { getTestApp, shutdownTestApp } = require('./setup');

const R5 = '/tx/r5';

describe('ISS-04: multi-value[x] Parameters.parameter rejected with 400', () => {
let app;

beforeAll(async () => {
app = await getTestApp();
}, 240000);

afterAll(async () => {
await shutdownTestApp();
});

const post = (op, parameter) =>
request(app).post(`${R5}/${op}`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/fhir+json')
.send({ resourceType: 'Parameters', parameter });

test.each([
['$expand url with valueUri + valueString', 'ValueSet/$expand', [
{ name: 'url', valueUri: 'http://hl7.org/fhir/ValueSet/administrative-gender', valueString: [] }
]],
['$validate-code code with valueCode + valueString', 'ValueSet/$validate-code', [
{ name: 'url', valueUri: 'http://hl7.org/fhir/ValueSet/administrative-gender' },
{ name: 'system', valueUri: 'http://hl7.org/fhir/administrative-gender' },
{ name: 'code', valueCode: 'male', valueString: {} }
]],
['$lookup system with valueUri + valueString', 'CodeSystem/$lookup', [
{ name: 'system', valueUri: 'http://hl7.org/fhir/administrative-gender', valueString: {} },
{ name: 'code', valueCode: 'male' }
]],
['$translate system with valueUri + valueString', 'ConceptMap/$translate', [
{ name: 'system', valueUri: 'http://hl7.org/fhir/administrative-gender', valueString: {} },
{ name: 'code', valueCode: 'male' },
{ name: 'targetSystem', valueUri: 'http://example.org/tgt' }
]],
['value[x] combined with resource', 'ValueSet/$expand', [
{ name: 'valueSet', valueUri: 'http://example.org/vs', resource: { resourceType: 'ValueSet', status: 'active' } }
]]
])('%s -> 400 invalid', async (_label, op, parameter) => {
const res = await post(op, parameter);
expect(res.status).toBe(400);
expect(res.body.resourceType).toBe('OperationOutcome');
expect(res.body.issue[0].code).toBe('invalid');
});
});
35 changes: 35 additions & 0 deletions tests/tx/fix-iss05-omop-iterator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Regression test for ISS-05: OMOP whole-system iteration throws typed HTTP 422 too-costly Issue.
*/

const path = require('path');
const { OMOPServicesFactory } = require('../../tx/cs/cs-omop');
const { OperationContext } = require('../../tx/operation-context');
const { Issue } = require('../../tx/library/operation-outcome');
const { TestUtilities } = require('../test-utilities');

describe('ISS-05: OMOP iterator throws typed 422 too-costly Issue', () => {
test('OMOPServices.iterator and nextContext throw Issue with statusCode 422', async () => {
const testDbPath = path.resolve(__dirname, '../../tx/data/omop-fragment.db');
const opContext = new OperationContext('en', await TestUtilities.loadTranslations());
const factory = new OMOPServicesFactory(opContext.i18n, testDbPath);
const provider = await factory.build(opContext, []);
try {
for (const call of [() => provider.iterator(null), () => provider.nextContext(null)]) {
let caught = null;
try {
await call();
} catch (e) {
caught = e;
}
expect(caught).toBeInstanceOf(Issue);
expect(caught.statusCode).toBe(422);
expect(caught.cause).toBe('too-costly');
expect(caught.msgId).toBe('CODESYSTEM_TOO_LARGE_TO_ITERATE');
expect(caught.message).toContain('too large');
}
} finally {
provider.close();
}
});
});
40 changes: 40 additions & 0 deletions tests/tx/fix-iss08-surrogate-pairs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Regression test for ISS-08: preserve non-BMP UTF-16 surrogate pairs in VCL and SNOMED SCG errors.
*/

const { parseVCL } = require('../../vcl/vcl-parser');
const { SnomedExpressionParser } = require('../../tx/sct/expressions');

describe('ISS-08: non-BMP UTF-16 surrogate pair safety in VCL and SNOMED SCG parsers', () => {
test('VCL lexer error preserves full astral character without lone surrogate escapes', () => {
let msg = '';
try {
parseVCL('😀');
} catch (e) {
msg = e.message;
}
expect(msg).toContain('😀');
expect(JSON.stringify({ msg })).not.toMatch(/\\ud[89a-f][0-9a-f]{2}/i);
});

test('SNOMED SCG parser error preserves full astral character and safe snippet without lone surrogates', () => {
const parser = new SnomedExpressionParser();
let msg = '';
try {
parser.parse('🩺-test-🧬');
} catch (e) {
msg = e.message;
}
expect(msg).toContain('🩺');
expect(JSON.stringify({ msg })).not.toMatch(/\\ud[89a-f][0-9a-f]{2}/i);

const longStr = 'a'.repeat(199) + '🩺';
let longMsg = '';
try {
parser.parse(longStr);
} catch (e) {
longMsg = e.message;
}
expect(JSON.stringify({ longMsg })).not.toMatch(/\\ud[89a-f][0-9a-f]{2}/i);
});
});
Loading
Loading