absent-sapphire
absent-sapphire2mo ago

Supabase throws error "unexpected end of input expecting field name (* or [a..z0..9_$])"

When my page loads one of the initial queries is https://.supabase.co/rest/v1/works?select=*&offset=0&limit=10&=ilike.%25 I think the &=ilike.%25 at the end is causing the error but I cannot figure out how to remove it
4 Replies
kapa.ai
kapa.ai2mo ago
Hi @ahnaf. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It looks like the issue is with the query string parameter &=ilike.%25 at the end of your URL. This part of the query is malformed and is causing the error "unexpected end of input expecting field name (* or [a..z0..9_$])". Based on the knowledge sources, there are a few things you can check and adjust: 1. Ensure Proper Filter Configuration: Make sure that your filter configuration is correctly set up. For example, if you are using the or operator, ensure that it is properly structured. Here is an example from the knowledge sources:
const { refetch: refetchOrders } = useList<any>({
resource: "contacts",
filters: [
{
operator: "or",
value: [
{
field: "firstname",
operator: "contains",
value: value,
},
{
field: "lastname",
operator: "contains",
value: value,
},
],
},
],
queryOptions: {
enabled: false,
onSuccess: (data) => {
const orderOptionGroup = data.data.map((item) =>
renderItem(
`#${item.id} - ${item.firstname} ${item.lastname}`,
`/contacts/show/${item.id}`
)
);
if (orderOptionGroup.length > 0) {
setOptions((prevOptions) => [
...prevOptions,
{
label: renderTitle("Contacts"),
options: orderOptionGroup,
},
]);
}
},
},
meta: {
select: "*",
},
});

const { refetch: refetchOrders } = useList<any>({
resource: "contacts",
filters: [
{
operator: "or",
value: [
{
field: "firstname",
operator: "contains",
value: value,
},
{
field: "lastname",
operator: "contains",
value: value,
},
],
},
],
queryOptions: {
enabled: false,
onSuccess: (data) => {
const orderOptionGroup = data.data.map((item) =>
renderItem(
`#${item.id} - ${item.firstname} ${item.lastname}`,
`/contacts/show/${item.id}`
)
);
if (orderOptionGroup.length > 0) {
setOptions((prevOptions) => [
...prevOptions,
{
label: renderTitle("Contacts"),
options: orderOptionGroup,
},
]);
}
},
},
meta: {
select: "*",
},
});

This example shows how to properly structure a filter with the or operator and ensure that the select meta property is correctly set. 2. Check for Incorrect Filter Operators: There might be an issue with the filter operators being used. According to the knowledge sources, there was a bug where contains and containss were reversed in the generateFilter function. Ensure that you are using the correct operators:
const filter: CrudFilter = {
operator: 'or',
value: [
{
field: 'name',
operator: 'contains',
value: 'test',
},
],
};

const filter: CrudFilter = {
operator: 'or',
value: [
{
field: 'name',
operator: 'contains',
value: 'test',
},
],
};

This should resolve to (name.ilike.test) instead of (name.contains.test). 3. Review Your Query Construction: Ensure that your query construction does not inadvertently add malformed parts. Double-check the logic that builds the query string to avoid adding unnecessary or incorrect parameters. If you continue to face issues, you might want to refer to the refine documentation on handling filters (https://refine.dev/docs/advanced-tutorials/data-provider/handling-filters/#handle-filters-in-a-data-provider) for more detailed guidance. If none of these solutions resolve your issue, please provide more details about how you are constructing your queries, and I can assist further. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@543682490951532554> kapa.ai is still learning and improving, please let us know how it did by reacting below
vicious-gold
vicious-gold2mo ago
Hey @ahnaf this could be an issue with supabase data provider. Can you create an issue on GitHub? Make sure to fill bug report fields it will be easier to help.
absent-sapphire
absent-sapphire2mo ago
okay thanks