SQL request was failed with the error: undefined

This issue took me a bit more time to debug than I would like to admit. It also gave no useful search results on Google and the Mendix Forum so I decided to write this short TIL

Question: What is causing the error SQL request was failed with the error: undefined on Native?

Answer: In most cases this is caused by missing READ access to any of the attributes/associations used in the XPath retrieve in the Native pages / Nanoflows.

The error below occurred in my project when a retrieve was performed in a Native Nanoflow. This retrieve had an XPath constraint where several date and integer attributes of the entity were compared against values calculated in the Nanoflow (in order to determine the current shift). The user executing the Nanoflow was missing READ access rights on the Shift.Shift.EndTimeInt attribute.

SQL request was failed with the error: undefined. Query: "SELECT Shift$Shift.[DynamicClass] AS "DynamicClass", Shift$Shift.[StartTime] AS "StartTime", Shift$Shift.[EndTime] AS "EndTime", Shift$Shift.[DisplayName] AS "DisplayName", Shift$Shift.[Shift$Shift_Plant] AS "Shift$Shift_Plant", Shift$Shift.[Name] AS "Name", _guidToTable.[guid] AS "_guidToTable.guid", _guidToTable.[tableName] AS "_guidToTable.tableName", _guidToTable.[readonlyAttrs] AS "_guidToTable.readonlyAttrs", _guidToTable.[syncId] AS "_guidToTable.syncId" FROM mx43065671436756187$Shift$Shift AS Shift$Shift JOIN mx43065671436756187$_guidToTable AS _guidToTable USING (guid) WHERE (Shift$Shift.[StartTimeInt] < Shift$Shift.[EndTimeInt]) LIMIT 1 OFFSET 0

The error itself does not really indicate that something is wrong with the access constraints (also Mendix Studio doesn’t give you an modelling error or warning). But now you know…