Skip to content

NullPointerException when there's not next token in HfqlFhirPathParser.determineDatatypeForPath #6720

@bratwurzt

Description

@bratwurzt

When calling:
SELECT deceased FROM Patient WHERE id IN search_match('deceased', 'true') order by meta.lastUpdated

At line 150:
lexer.peekNextToken(HfqlLexerOptions.FHIRPATH_EXPRESSION_PART)

throws an NPE exception.
https://github.com/hapifhir/hapi-fhir/blame/57ee0240d46e1ace94148313750343e320e29606/hapi-fhir-jpaserver-hfql/src/main/java/ca/uhn/fhir/jpa/fql/parser/HfqlFhirPathParser.java#L150C7-L150C7

Solution:
if (childDefForNode != null)
becomes
if (childDefForNode != null && lexer.hasNextToken(HfqlLexerOptions.FHIRPATH_EXPRESSION_PART))

Edit:

I've realized that selecting deceased from Patient is not correct and you should either do it like this:
deceased.ofType(dateTime)
or
deceased.ofType(boolean)

I'll leave this issue for a better formatted exception. Currently it is:
Cannot invoke "ca.uhn.fhir.jpa.fql.parser.HfqlLexerToken.getToken()" because the return value of "ca.uhn.fhir.jpa.fql.parser.HfqlLexer.peekNextToken(ca.uhn.fhir.jpa.fql.parser.HfqlLexerOptions)" is null
with pull request:
"Unexpected end of stream (expected .ofType() function after polymorphic item <item_name>)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions