Skip to content

fix: convert dict entities to text strings for highlights field (Fixes #386)#667

Merged
ritesh-1918 merged 1 commit into
ritesh-1918:gssocfrom
lb1192176991-lab:fix/highlights-entityinfo-500-386
May 31, 2026
Merged

fix: convert dict entities to text strings for highlights field (Fixes #386)#667
ritesh-1918 merged 1 commit into
ritesh-1918:gssocfrom
lb1192176991-lab:fix/highlights-entityinfo-500-386

Conversation

@lb1192176991-lab

Copy link
Copy Markdown

What

The /ai/analyze endpoint crashes with a 500 error because the highlights field in TicketResponse is typed as list[str] but receives list[dict] objects.

Root cause: ner_service.extract_entities() returns list[dict] with keys {"text", "label", "confidence"}. When this list is passed to highlights=[e.text for e in entities], it crashes with AttributeError: dict object has no attribute text because the entities variable is still list[dict] at that point in the code (it is only converted to list[EntityInfo] in the separate entities= parameter).

Fix: Changed line 1855 from:

highlights=[e.text for e in entities] if entities else []

to:

highlights=[e.get("text", "") for e in entities] if entities else []

The analyze_stream() endpoint already had the correct form (e.get("text", "")) on line 2019 — it was only the analyze_only() function that had the wrong access pattern.

Why

Users hitting the /ai/analyze endpoint get a 500 error when NER entities are present, making the AI analysis feature completely broken whenever entities are detected. Pydantic v2 cannot coerce dict objects into str.

Testing

  • When entities = [{"text": "Python", "label": "tech", "confidence": 0.95}], highlights becomes ["Python"]
  • When entities = [], highlights becomes []
  • When entities = [{"label": "tech"}] (missing text key), highlights becomes [""] ✓ (graceful fallback)

…ritesh-1918#386)

entities from ner_service.extract_entities() returns list[dict] with
keys {"text", "label", "confidence"}, not EntityInfo objects. The
highlights field expects list[str].

Changed highlights=[e.text for e in entities] to
highlights=[e.get("text", "") for e in entities] to properly extract
text from dict entries.
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

@lb1192176991-lab is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cedd1373-7888-4bfb-a5f3-8acfd4a6739c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ritesh-1918 ritesh-1918 added gssoc GirlScript Summer of Code gssoc:approved GSSoC Approved PR level:advanced Advanced level difficulty quality:exceptional Exceptional code quality type:bug Bug fix labels May 31, 2026
@ritesh-1918

Copy link
Copy Markdown
Owner

Superb implementation, @lb1192176991-lab! I've successfully resolved all conflicts in your PR and queued it for merging into gssoc.

⚠️ MANDATORY STEPS FOR LEADERBOARD CREDITS:
To ensure you receive full points, please make sure you have taken 10 seconds to:

Keep up the outstanding work! Let's build together! 🔥

@ritesh-1918 ritesh-1918 merged commit c7a1cfd into ritesh-1918:gssoc May 31, 2026
2 of 3 checks passed
@ritesh-1918 ritesh-1918 added the level:intermediate Intermediate level difficulty label May 31, 2026
@ritesh-1918

Copy link
Copy Markdown
Owner

Hi @lb1192176991-lab! 🙌

Thank you so much for your excellent contribution: "fix: convert dict entities to text strings for highlights field (Fixes #386)"! We really appreciate the high-quality code and effort you have put into the platform.

Just a quick, friendly heads-up as we prepare our manual merging and verification queues—please make sure to complete all the mandatory community steps listed below.

Once those manual steps are verified, we'll get your PR officially merged into the gssoc branch (or keep it neatly cataloged if closed as integrated) and assign it the highest possible GSSoC S-Tier labels to maximize your leaderboard points!

Let's build something amazing together! 🚀🔥


🌟 Community Support & Network Steps (Take 10 Seconds!)

As we prepare our manual verification and merging queues, please make sure you have taken a moment to complete these required steps to finalize your points:

  1. Star this repository: https://github.com/ritesh-1918/HELPDESK.AI (Mandatory)
  2. 🍴 Fork this repository: https://github.com/ritesh-1918/HELPDESK.AI/fork (Mandatory)
  3. 👤 Follow @ritesh-1918 on GitHub: https://github.com/ritesh-1918 (Mandatory - manual step)
  4. 💼 Connect on LinkedIn: https://www.linkedin.com/in/ritesh1908/ (Mandatory)

Note: Having these steps completed manually is required before your PR points are officially cleared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC Approved PR gssoc GirlScript Summer of Code level:advanced Advanced level difficulty level:intermediate Intermediate level difficulty quality:exceptional Exceptional code quality type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants