Stream: shorthand
Topic: Interesting GoFSH bug
Hank Lenzi (Dec 18 2021 at 13:35):
Hello --
Not exactly sure this is a real bug, but I just passed a bunch of files through gofsh and one of them (below) had a "/" in the "name:" (see below) and this caused gofsh to convert the file opening a new "/Cor" directory
{
"resourceType": "CodeSystem",
"id": "br-core-codesystem-patient-raceethnicity-race",
"meta": {
"lastUpdated": "2020-03-11T18:20:19.538+00:00"
},
"language": "pt-BR",
"url": "http://www.saude.gov.br/fhir/r4/CodeSystem/BRRacaCor",
"version": "201701A",
"name": "Raça/Cor",
"status": "active",
"experimental": false,
"date": "2020-03-11T18:20:40.0457007+00:00",
"publisher": "Ministério da Saúde do Brasil",
"description": "Códigos para representação de raça/cor.",
"content": "complete",
"concept": [
{
"code": "01",
"display": "Branca"
},
{
"code": "02",
"display": "Preta"
},
{
"code": "03",
"display": "Parda"
},
{
"code": "04",
"display": "Amarela"
},
{
"code": "05",
"display": "Indígena"
}
]
}
This is interesting because, of course, per the spec for the string data type, this is not a bug (https://hl7.org/fhir/r4/datatypes.html#string)
Just thought you guys might like to know this. I'd be interested in your comments.
Cheers,
Hank.
Hank Lenzi (Dec 18 2021 at 21:56):
If this wasn't clear: "name": "Raça/Cor" (← this string) caused gofsh to split into a new directory (the string means: "Race/Color").
Jean Duteau (Dec 18 2021 at 22:24):
True that it’s not really a bug but the name of a profile is expected to be computer friendly so the / character would raise a warning
Mint Thompson (Dec 20 2021 at 12:57):
This is absolutely a real bug, as a maliciously crafted input could end up overwriting a file in an arbitrary location. I'll let the team know ASAP.
Hank Lenzi (Dec 20 2021 at 14:09):
Oh, boy I'm glad I reported this!
Chris Moesel (Dec 20 2021 at 14:13):
Yep. We'll work on a fix!
@Jean Duteau is correct, however, that names should not contain characters like /
. According to the spec, names should be alphanumeric. More specifically, they should start with an uppercase letter and be followed by any combination of uppercase or lowercase letters, digits, and the underscore character (_
). That said, it is SHOULD, not SHALL. See StructureDefinition.name.
Elliot Silver (Dec 20 2021 at 16:31):
Is that invariant enforced anywhere? (I’d never noticed the capitalization requirement before, and suspect many of my resources are non-conformant.) Actually, seems like something the IG publisher should check.
John Moehrke (Dec 20 2021 at 17:11):
sushi does throw an error, I recall that the IG publisher does "warn". I am sure I recall seeing that as a warn or error. ... but if you are not using sushi to start with (why would you be using GoFSH), or the IG publisher, or a validator, etc. I think in this case GoFSH is starting with an IG that was not formally published (or not lately)
John Moehrke (Dec 20 2021 at 17:14):
but Postel's Law needs to be applied to GoFSH too. Be robust, don't assume well structured input.
Chris Moesel (Dec 20 2021 at 20:00):
For GoFSH, except in very extreme circumstances, we prioritize consistency w/ the input source over best practice / correctness. E.g., if you pass GoFSH a FHIR project, it will try to create FSH that reflects that FHIR project as closely as possible (warts and all). If we changed ids/names to follow best practices then we'd be creating a project that is not backward compatible to the input project you passed us. That doesn't seem like a good idea, so we try not to do that.
Chris Moesel (Dec 21 2021 at 03:13):
@Hank Lenzi - this bug is fixed in the newly released GoFSH 1.4.2. See my other post for details.
Hank Lenzi (Dec 21 2021 at 14:25):
Chris Moesel said:
Hank Lenzi - this bug is fixed in the newly released GoFSH 1.4.2. See my other post for details.
Fantastic! Kudos for the quick response!
Last updated: Apr 12 2022 at 19:14 UTC