Skip to content

Fix onboarding orphan prospect query#349

Merged
michaelmwu merged 1 commit into
mainfrom
michaelmwu/import-xlsx-prospects
Jun 29, 2026
Merged

Fix onboarding orphan prospect query#349
michaelmwu merged 1 commit into
mainfrom
michaelmwu/import-xlsx-prospects

Conversation

@michaelmwu

@michaelmwu michaelmwu commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix the onboarding orphan-intake lookup so the prospect contact-type pattern is passed as a psycopg parameter instead of an inline %prospect% SQL literal.
  • Update the regression test to assert the placeholder and bound parameter.

Root Cause

The onboarding queue always runs the orphan-intake query. That query included people.contact_type ILIKE '%prospect%' inside a psycopg parameterized statement, so psycopg parsed %p as an invalid placeholder and raised ProgrammingError: only '%s', '%b', '%t' are allowed as placeholders, got '%p'.\n\n## Validation\n- uv run --package api pytest tests/unit/test_backend_api.py -q\n- pre-commit hooks on commit: ruff, ruff format, Pyrefly\n

Summary by CodeRabbit

  • Bug Fixes
    • Improved how dashboard intake submissions are filtered so matching is handled consistently with query parameters.
    • Updated related validation to confirm the filter value is passed safely and correctly during execution.

Copilot AI review requested due to automatic review settings June 29, 2026 12:25
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8395e671-5672-4bcd-b02c-88c7c7390f3c

📥 Commits

Reviewing files that changed from the base of the PR and between 7167b7a and 73de6ad.

📒 Files selected for processing (2)
  • apps/api/src/five08/backend/api.py
  • tests/unit/test_backend_api.py

📝 Walkthrough

Walkthrough

In _list_dashboard_orphan_intake_submissions, the people.contact_type ILIKE '%prospect%' SQL literal is replaced with a ILIKE %s placeholder, and the params list is pre-populated with "%prospect%". The corresponding unit test assertion is updated to match.

Changes

Parameterize contact_type ILIKE filter

Layer / File(s) Summary
Parameterized ILIKE filter and test
apps/api/src/five08/backend/api.py, tests/unit/test_backend_api.py
SQL query uses ILIKE %s instead of an inlined literal; params list is initialized with "%prospect%"; test asserts the placeholder and bound parameter value.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit once wrote SQL by hand,
Strings baked in — not quite as planned.
Now %s holds the key,
Parameters roam free,
Safer queries across the land! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: fixing the onboarding orphan prospect query.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch michaelmwu/import-xlsx-prospects

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a psycopg placeholder parsing error in the dashboard onboarding “orphan intake submissions” query by parameterizing the prospect ILIKE pattern instead of embedding a %prospect% literal in the SQL. This aligns with the repo’s existing DB access pattern (cursor.execute(trusted_sql(sql), params)) and prevents ProgrammingError triggered by stray % sequences in query strings.

Changes:

  • Replace people.contact_type ILIKE '%prospect%' with people.contact_type ILIKE %s and bind "%prospect%" via query parameters.
  • Update the unit regression test to assert the SQL placeholder and the bound parameter value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/api/src/five08/backend/api.py Parameterizes the prospect ILIKE filter to avoid psycopg placeholder parsing errors.
tests/unit/test_backend_api.py Adjusts regression assertions to validate placeholder usage and bound params.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelmwu michaelmwu added this pull request to the merge queue Jun 29, 2026
Merged via the queue into main with commit 039564f Jun 29, 2026
12 checks passed
@michaelmwu michaelmwu deleted the michaelmwu/import-xlsx-prospects branch June 29, 2026 12:42
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.

2 participants