Filter Broken or Buggy?

Describe the problem/error/question

I’m looking up rows in a google sheet that have empty gpslat and gpslon fields. They are represented coming into the filter like this:

{
"row_number": 
9,
"address": 
"1210 Danforth Ave",
"gpslon": 
-79.3318173,
"gpslat": 
43.6817327499999
},

The filter is checking to see if gpslon is empty as a string, but it’s returning all the records with row_number and address being the same, but gpslat and gpslon as empty strings for some reason.

{
"row_number": 
9,
"address": 
"1210 Danforth Ave",
"gpslon": 
"",
"gpslat": 
""
},

It’s changing records. It’s completely misbehaving.

What is the error message (if any)?

No error messages. Just modifying incoming json objects which is not what this node should do.

Please share your workflow

It’s a filter node. Input jason as above. Output as above. This single node is the problem.

Share the output returned by the last node


[
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
},
{
"row_number": 
28,
"address": 
"1205 Queen St W #3",
"gpslon": 
"",
"gpslat": 
""
}
]

Information on your n8n setup

  • n8n version:

  • 1.81.4

  • Database (default: SQLite):
    Google Sheets, but SQLite for the log apparently. I don’t look at it.

  • n8n EXECUTIONS_PROCESS setting (default: own, main):
    main

  • Running n8n via (Docker, npm, n8n cloud, desktop app):
    npm no docker.

  • Operating system:
    Almalinux 9 headless

Could you share the output returned by the Google Sheet node?

The sheet is being updated. But it was updated before, so it’s the same as the input. The filter is allowing the update to happen to previously updated rows.

This is how you could achieve what you need:

The no operation is just an example, you can replace it with what you really wanna do.

I’m sorry but you’ll have to explain what you mean. The filter is before the Loop node, in order to find blank entries. There’s no sense in grabbing thousands of records in order to loop through them. Just find the blank ones. It’s much quicker.

The above was just an expanded version of the filter since you said you were unable to get it working right. Essentially, the filter would do the exact same thing I did above:

  • loop through the results of Google Sheets
  • use an if statement to find the results

If you notice, that’s what the above workflow is doing. In any case, if you’re not interested in that, here’s what I attempted with the plain filter node and it works fine:

I don’t see it being much different than yours, but it seems to work:

Two things. First, this is the wrong approach. You don’t fetch records then iterate through them. You’ve shown 4. Situations could have thousands, which means filtering then looping around to the next one.

Second, the issue I’m talking about here, is that the filter on the found set, was not working. The OP shows that the output from the filter actually was changing the found records by updating the fields in the json to gpslat: ‘’ and gpslon: ‘’, which is wrong. That is a bug. In my found records, there was one that was blank that needed to be found by the filter.

@daBee, I looked at your workflow and the best approach towards your problem is to retrieve the empty records from Google Sheet directly. The Google Sheet node has a build in filter section, by using it you should be able to only retrieve the records without gpslon or gpslat.

Filters Option

Example Workflow

Output

Implementation

Let me know if it helped!

2 Likes

@daBee almost forgot, I made a sample data set to test the workflow I gave you. You can find the sample data set here!

Ya I’ve been using that since my last post. Onto other issues now. The problem with multiple tests is that the workflow remembers old records/memories so it iterates through more than it should. The new lookup doesn’t really pertain.

@daBee, if needed you can make a new post and explain the issue you’re facing. You should probably also mark this question as resolved so others may know that you don’t require futher assistance with this matter.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.