Skip to content

Conversation

y0no
Copy link

@y0no y0no commented Sep 12, 2025

Checklist

  • Read CONTRIBUTING.md.
  • PR title is short and non-generic (see previously merged PRs for examples).
  • PR only implements a single feature or fixes a single bug.
  • Tests passing (uv run pytest tests)?
  • Lint / pre-commits passing (pre-commit run --all-files)?

Description

This PR aims to provide a way to lookup on table over multiple columns and values. The implementation is compatible with the old syntax and the new one.

Currently the tests are not implemented in case the feature is not validated. I think there is a better way to implement this feature for example with a filter field which accept an array of key=value strings..But I don't know how to do it without breaking the old syntax.

Steps to QA

  1. Add a lookup or lookup_many node on a workflow
  2. Add two column names on column field
  3. Add two value names on value field
  4. See if a row is selected with multiple search criteria.

Summary by cubic

Add multi-column filtering to table lookups. You can now pass lists of columns and values; single-column calls still work.

  • New Features
    • lookup and lookup_many accept column: str | list[str] and value: Any | list[Any].
    • Validates one-to-one column/value pairs; raises a clear error on mismatch.
    • lookup now calls lookup_many with limit=1 for consistent behavior.
    • Sends column/value lists to TablesService.lookup_rows; existing limit checks remain.

@y0no y0no changed the title Lookup table on multiple columns WIP: Lookup table on multiple columns Sep 12, 2025
@y0no y0no changed the title WIP: Lookup table on multiple columns feat : Lookup table on multiple columns (WIP) Sep 12, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="packages/tracecat-registry/tracecat_registry/core/table.py">

<violation number="1" location="packages/tracecat-registry/tracecat_registry/core/table.py:34">
lookup now returns a list instead of a single record or None, breaking the function’s return contract and callers’ expectations</violation>

<violation number="2" location="packages/tracecat-registry/tracecat_registry/core/table.py:66">
Typo in comment: &quot;on value&quot; should be &quot;one value&quot; for clarity</violation>
</file>


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

)
# Since we set limit=1, we know there will be at most one row
return rows[0] if rows else None
return await lookup_many(table=table, column=column, value=value, limit=1)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lookup now returns a list instead of a single record or None, breaking the function’s return contract and callers’ expectations

Prompt for AI agents
Address the following comment on packages/tracecat-registry/tracecat_registry/core/table.py at line 34:

<comment>lookup now returns a list instead of a single record or None, breaking the function’s return contract and callers’ expectations</comment>

<file context>
@@ -23,23 +23,15 @@ async def lookup(
-        )
-    # Since we set limit=1, we know there will be at most one row
-    return rows[0] if rows else None
+    return await lookup_many(table=table, column=column, value=value, limit=1)
 
 
</file context>
Suggested change
return await lookup_many(table=table, column=column, value=value, limit=1)
return next(iter(await lookup_many(table=table, column=column, value=value, limit=1)), None)
Fix with Cubic

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Signed-off-by: y0no <y0no+github@y0no.fr>
@y0no y0no changed the title feat : Lookup table on multiple columns (WIP) feat : Lookup table on multiple columns Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant