leaf
leaf copied to clipboard
Insufficient debug info in logs when "Error Loading Dataset"
I am trying to use "Add More Data" having defined an additional dataset per Adding New Datasets.
Despite the request (http://localhost:3000/api/cohort/b9b5433e-f36b-1410-8d86-0052d9c6700c/dataset?datasetid=a4b5433e-f36b-1410-8d86-0052d9c6700c&shape=-1) returning HTTP 500, I only get Information-level log entries. The most informative is "MessageTemplate": "Dataset compiler validation context. Context:{@Context}"
. It includes "State": "Ok"
.
The subsequent log event is "Executing HttpStatusCodeResult, setting HTTP status code {StatusCode}".
Should there be another log event in between? There's no current log event giving me the complete SQL selecting this dataset's values only for the selected cohort, nor can I see a log event with the traceback of an error.
Hmm... maybe this is more specific to our case, as making other errors in the dataset definition results in a Failed to fetch dataset.
log entry. So there seems to be a case that is silently resulting in an HTTP 500 before Compiled dataset execution context
My specific case may be related to the use of a WITH clause preceding SELECT...
Hi @jnothman,
Ah the WITH
may be the issue, which would result in an invalid SQL statement. Leaf wraps your SQL statement in a CTE already, where the dataset
parameter in the below function is the SQL statement you compose:
So the CTE-within-a-CTE is invalid. Leaf expects your SQL to be of the traditional SELECT
... FROM
... WHERE
variety.
An alternative would be to first make a View
and include the CTE there, then call the View
.
Can I nest a SELECT clause within FROM? that might also work.
It does!
Still, the lack of full SQL statement in the logs made it much harder to dig into.
@jnothman, can you check your logs for an entry with a message like "Compiled dataset execution context:"?
You should be able to find the SQL statement under Properties
.Context
.CompiledQuery
.
No I'm not seeing that log. I assume it's breaking on the previous line in compiler.BuildDatasetSql(validationContext.Context);
but I'm surprised I see nothing like a traceback, just a log for setting HTTP 500.