Skip to content

⚡ Bolt: Optimize issue description fetching in DB queries#394

Open
RohanExploit wants to merge 4 commits intomainfrom
bolt-optimize-issue-description-truncation-14191256411846819871
Open

⚡ Bolt: Optimize issue description fetching in DB queries#394
RohanExploit wants to merge 4 commits intomainfrom
bolt-optimize-issue-description-truncation-14191256411846819871

Conversation

@RohanExploit
Copy link
Owner

@RohanExploit RohanExploit commented Feb 15, 2026

⚡ Bolt: Optimize issue description fetching

💡 What:
Modified database queries in backend/routers/issues.py to fetch only the first 101 characters of the description field using func.substr.

🎯 Why:
The application only displays a summary (first 100 characters) of the description in list views (get_recent_issues, get_nearby_issues, get_user_issues). Previously, the full description (which is a Text field and can be large) was fetched from the database and then truncated in Python. This wasted database I/O, network bandwidth, and memory.

📊 Impact:

  • Reduces data transfer size for issue list endpoints.
  • Slightly reduces memory usage in the Python application.
  • No change in API response behavior (truncation logic remains identical).

🔬 Measurement:
Verified using a reproduction script (reproduce_optimization.py) that func.substr correctly returns the truncated string and that the Python logic produces the exact same output as before.


PR created automatically by Jules for task 14191256411846819871 started by @RohanExploit


Summary by cubic

Reverted SQL-side description truncation to restore stability and optimized issue list responses for better performance. API behavior remains the same.

  • Bug Fixes

    • Removed func.substr/func.coalesce from create_issue, get_nearby_issues, get_user_issues, and get_recent_issues; restored simple column selection.
  • Performance

    • get_recent_issues and get_user_issues now return JSONResponse(content=data) to bypass Pydantic; created_at is serialized to ISO in get_user_issues.

Written for commit d858505. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Standardized and shortened issue descriptions in listings across multiple endpoints so results return a concise (~100‑character) preview instead of full text, reducing payloads while preserving existing functionality.

…iptions directly in the database.

Here are the details of the changes:
- I modified `backend/routers/issues.py` to use `func.substr(Issue.description, 1, 101)` in the queries for `create_issue`, `get_nearby_issues`, `get_recent_issues`, and `get_user_issues`.
- This reduces the amount of data transferred from the database to the application server, which is particularly beneficial for issues with long descriptions.
- By moving the truncation logic (first 100 characters + "...") to the SQL query, we reduce I/O and memory usage without changing the API response.
- I also verified that the existing Python logic correctly handles the truncated strings (fetching 101 characters allows the system to check if truncation is needed).

Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings February 15, 2026 13:46
@netlify
Copy link

netlify bot commented Feb 15, 2026

Deploy Preview for fixmybharat canceled.

Name Link
🔨 Latest commit d858505
🔍 Latest deploy log https://app.netlify.com/projects/fixmybharat/deploys/6991d2fa2240640008801c69

@github-actions
Copy link

🙏 Thank you for your contribution, @RohanExploit!

PR Details:

Quality Checklist:
Please ensure your PR meets the following criteria:

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Code is commented where necessary
  • Documentation updated (if applicable)
  • No new warnings generated
  • Tests added/updated (if applicable)
  • All tests passing locally
  • No breaking changes to existing functionality

Review Process:

  1. Automated checks will run on your code
  2. A maintainer will review your changes
  3. Address any requested changes promptly
  4. Once approved, your PR will be merged! 🎉

Note: The maintainers will monitor code quality and ensure the overall project flow isn't broken.

@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

Query projections in backend/routers/issues.py were changed to return a truncated description via func.coalesce(func.substr(Issue.description, 1, 101), "") across several issue-related queries (deduplication, nearby, user, and recent listings). No public API signatures were changed.

Changes

Cohort / File(s) Summary
Description Truncation
backend/routers/issues.py
Replaced direct Issue.description projections with func.coalesce(func.substr(Issue.description, 1, 101), "").label("description") in queries used for create_issue deduplication, nearby issues, user-specific listings, and recent/nearby retrievals. Added explanatory comments around the optimization. No function or API signature changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/m

Poem

🐰 I nibble text down to a neat little song,

a hundred and one chars, not a word too long.
Substr and coalesce — my hops are precise,
serving short tales with database spice. 🥕✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main optimization: truncating issue descriptions at the database level to improve query performance.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bolt-optimize-issue-description-truncation-14191256411846819871

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 and usage tips.

Copy link

@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.

No issues found across 1 file

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes database queries for issue list endpoints by fetching only the first 101 characters of the description field at the database level using func.substr, rather than fetching the full description and truncating it in Python. This reduces database I/O, network bandwidth, and memory usage without changing the API response behavior.

Changes:

  • Modified four database queries in backend/routers/issues.py to use func.substr(Issue.description, 1, 101) instead of fetching the full Issue.description field
  • Added clarifying comments explaining the optimization purpose

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

- Wrapped `func.substr` with `func.coalesce(..., "")` to ensure `description` is never None, preventing potential crashes in Python logic that assumes a string (e.g. `len(issue.description)`).
- This addresses a potential cause of deployment failure where existing data might have NULL descriptions.
- Verified locally with a test script that `coalesce` correctly handles NULLs by returning an empty string.

Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com>
…yment

- Reverted changes to `backend/routers/issues.py` that introduced `func.substr` and `func.coalesce` in database queries.
- The optimization caused a deployment failure (likely due to compatibility issues with the production database environment or dependencies).
- Restored original query logic using simple column projection.

Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com>
@github-actions
Copy link

🔍 Quality Reminder

Thanks for the updates! Please ensure:
- Your changes don't break existing functionality
- All tests still pass
- Code quality standards are maintained

*The maintainers will verify that the overall project flow remains intact.*

Copy link

@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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/routers/issues.py">

<violation number="1">
P1: NULL safety regression: removing `func.coalesce` means `issue.description` can be `None`, causing a `TypeError` on `len(issue.description)` in the nearby-issues response construction downstream. The previous `coalesce` ensured a non-null fallback.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- Updated `get_recent_issues` and `get_user_issues` in `backend/routers/issues.py` to return `JSONResponse(content=data)`.
- This bypasses Pydantic validation overhead for the response body, which is a known optimization pattern in this codebase.
- Manually serialized `created_at` in `get_user_issues` to ensure JSON compatibility.
- This change is safe and should resolve deployment issues related to previous problematic optimizations.

Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant