Skip to main content
Planned for development

Listing functions by filtering on metadata returns empty list

  • February 24, 2025
  • 10 replies
  • 94 views

Anders Brakestad
Seasoned ⭐️⭐️⭐️

Hello!

We have added specific metadata fields to our Cognite Functions (project name, git branch, git commit hash, git actor, etc) so we can target very specific deployments in debugging and development. But I am not able to list cognite functions with the python sdk by filtering on metadata. For example, the following 

 

client.functions.list(metadata={"my_key": "my_val"}, limit=None)

 

just returns an empty list.  I know the functions are there, since I can target some of them by using the external id prefix argument.

 

We have the same metadata fields to our time series and sequences, and I am able to successfully list these by using their metadata argument.

 

Is this a bug in the API?

10 replies

Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Forum|alt.badge.img+8
  • Expert ⭐️⭐️⭐️⭐️
  • February 24, 2025

@Anders Brakestad I tried from my end and I was able to list the functions with the relevant metadata. Can you please let me know the SDK version that you are using? Also can you try again using the latest SDK version(7.73.4)?

The missing filter parameter metadata was added to client.functions.list from SDK v7.54.1


Anders Brakestad
Seasoned ⭐️⭐️⭐️
  • Author
  • Seasoned ⭐️⭐️⭐️
  • February 24, 2025

Hi and thanks for the fast reply.

I was using version 7.73.3. I now upgraded to version 7.73.4 of the cognite SDK, but I still cannot list functions with metadata.

 

If it helps I want to list functions with 

metadata={"project": "alarm dashboard backend"}

in the “abp-dev” tenant.


Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Forum|alt.badge.img+8
  • Expert ⭐️⭐️⭐️⭐️
  • February 24, 2025

I don’t have access to the project. But it retruns an empty list when the key, value pair does not match any existing function.

@Jørgen Lund any idea regarding this issue?


@Anders Brakestad When you’re doing 

client.functions.list(metadata={"my_key": "my_val"}, limit=None)

does the function have other key and value pairs as well? If it does, that explains why. It filters on the metadata as a whole.


Anders Brakestad
Seasoned ⭐️⭐️⭐️
  • Author
  • Seasoned ⭐️⭐️⭐️
  • February 25, 2025

Yes it does.

But why different implementation for functions and other CDF data? The expected functionality is to filter on any metadata matches. That is how we search for stuff in CDF. Matching the entire metadata dict makes no sense.

 

😉


Yes, I agree that it would be more useful to filter on parts of the metadata. I’ll confer with our PM about this.


Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Forum|alt.badge.img+8
  • Expert ⭐️⭐️⭐️⭐️
  • February 26, 2025

@Anders Brakestad ​@Henrik Eiding shall I convert this to a product idea?


Anders Brakestad
Seasoned ⭐️⭐️⭐️
  • Author
  • Seasoned ⭐️⭐️⭐️
  • February 26, 2025

Yes, that would be great :) Thanks!


Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Forum|alt.badge.img+8
  • Expert ⭐️⭐️⭐️⭐️
  • February 26, 2025

@Anders Brakestad Done


Markus Pettersen
MVP ⭐️⭐️⭐️⭐️⭐️
Forum|alt.badge.img+1
  • MVP ⭐️⭐️⭐️⭐️⭐️
  • June 24, 2025

I’ll add my voice to this, filtering on metadata as a whole is not useful. Filtering on parts of metadata as with other resources is what we consider as expected behavior. Are this the only resource where this happens or are there other instances where the filter is on the metadata as a whole, because if so then those should also be updated to filter on parts of metadata (the key value pairs specified in the request).