500 Internal Server Error: Cannot extract elements from a scalar

Options

I am getting a 500 Error, with the below message (screenshot) in the request history output.

The context is that this is part of a ~20 filter + fuzzy search and sort page on a Bubble front end, sorting across a database of recipes in a Xano back end. The API connection in Bubble is a 'POST' and a 'Data' type.

The fuzzy search is working like a dream and the search and filter seems to be working fine for all but one of the filters 'Months in Season'. The situation where the error appears is in the case where I clear all filters and only filter by values in this 'Months in Season' filter. As soon as I apply any Month value in this filter, there are zero search responses on Bubble and I get this 500 Internal Server error.

Oddly, when this 'Months in Season' filter (which is an array in the bubble API connector, and enters Xano as a list enum input) is applied in tandem with and after first applying one of the other filters, or entering a value to the fuzzy search, it seems to work fine. So I can pass the same array of values for 'month' and it will work depending on whether other filters are also taking a value. I also think this error was not present a couple of days ago.

I am not sure if the issue is in Bubble or Xano. I have tried deleting and rebuilding almost every step touched by the 'months' input in Xano, deleted and rewrote the array in the API connector json, rewrote everything in the multidropdown in Bubble that selects the values. There is a 'cuisine geography' filter that follows exactly the same logic and which works, and I have checked step by step (I think) for any discrepencies between how the 2 filters are set-up and can't find anything. I've tried clearing my browser cache and am about to try previewing in another browser just in case.

Setting up the same values in the Xano 'Run & Debug' as I am entering in the Bubble browser doesn't seem to lead to an error. (Next step is to try and re-initialise the API call with the same values that are throwing the error when I change the filter in the browser)

Normally in situations like this its something simple at the root and I figure it out after following tracks back, but this time I'm flummoxed.

Only thing I can think of specific to this filter that might be connected to this on is that in Bubble, the choices source in the multidropdown is a 'Months' Option set. This was throwing a bug a few days ago and not displaying one of the month values, so I deleted and replaced just that one month. That said - I can't see the logic for how this would play through to an array/scalar error in Xano.

Grateful for any support/ideas!

Tagged:

Answers

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Hi, Antony. "Setting up the same values in the Xano 'Run & Debug' as I am entering in the Bubble browser doesn't seem to lead to an error" to me is likely the key here, and the source for the cause is going to live in the request history. We'll want to investigate the data Bubble is sending and compare it to what you're doing if you execute via Run & Debug and adjust from there, either something on the Bubble side or transform the input in the function stack.

  • Antony H
    Antony H Member
    edited March 2023
    Options

    Thanks for your quick response @Chris Coleman . I have just run some more tests using same filter settings for 1) Bubble Preview 2) Reinitialize API in API connector 3) Run & Debug in Xano. Looks like I mis-spoke earlier. When I'm careful to set things up the same in all three contexts, the error on the 'months in season' appears in the same way in each of (1), (2) and (3). E.g., it appears when 'months in season' is the only filter set, and everything else set to null (a couple of checkboxes set to false). The following are also consistent in all three contexts. i) When I add values to one or more additional filters alongside 'months in season', the errors doesn't occur; ii) When I add values only to a single other filter that appears to be set up in the same way as 'months in season', and leave the 'months in season' filter blank, the errors also doesn't occur.

    So seems to be something specific about the way 'months in season' is set up/how I'm dealing with this filter in Xano - but I can't figure out what I'm doing differently/incorrectly with it.

    Working through steps: in run/debug and API connector it is an array in the form below, with a max of 3 entries allowed (error occurs whether there are 1, 2 or 3 entries.)

    "months": [ "Mar", "Apr", "May" ]

    The input 'months' in the Post API on Xano is in form:

    enum[]; required: no; structure: list; Nullable: yes; API access: Public; Max # list items: 3. The allowable values are Jan; Feb, Mar… Dec

    In the functions stack I do the following with the 'months' input. (both steps here are same insofar as I can tell as what I do with the 'cuisine geography' input that has same structure and is working fine).

    1. Create a new variable (var_months) to strip out any null values (below)
    2. Include var_months as part of the filter query (2nd image below)

    In the debugger, the function appears to run as far as the filter query (the last step) and throws the error at that point. From what I can tell with variables switched on in the debugger, the months variable appears to enter the query step in the form I expect - copy pasted below (but I could very well be wrong…)

    {name: var_months,value: [Mar,Apr,May]}

    That's about all I have. Still flummoxed 🧐. Won't be surprised if it turns out to be a simple error somewhere but I can't see what.

  • Antony H
    Antony H Member
    Options

    Have paused trying to fix this one for now. I have implemented a simple workaround that does most of what I want the filter to do (and as this works, that might also shed some light)

    I simply changed the 'months in season' term on the query from an overlap condition with the database to a contain condition, and restricted the number of months that can be entered as input to one.

    Good enough for now but I'm still confused as to why the function didn't appear to treat the months in season input as an array/list under certain conditions when it had been set up as an array/list.