Skip to content

fix(llm): remove duplicated _appears_truncated stub#782

Open
NightingaleCen wants to merge 1 commit into
srbhr:mainfrom
NightingaleCen:fix/llm-duplicate-appears-truncated
Open

fix(llm): remove duplicated _appears_truncated stub#782
NightingaleCen wants to merge 1 commit into
srbhr:mainfrom
NightingaleCen:fix/llm-duplicate-appears-truncated

Conversation

@NightingaleCen
Copy link
Copy Markdown
Contributor

@NightingaleCen NightingaleCen commented May 4, 2026

Related Issue

Regression introduced by #775 (fix(llm): resolve DeepSeek 500 / Failed to analyze resume (#706), commit 4dda99f). No dedicated issue tracks this — the symptom is uv run app failing immediately at import time with an IndentationError, so anyone on main cannot start the backend at all.

Description

app/llm.py ends up with two definitions of _appears_truncated, both broken, so the entire backend crashes at import time:

File ".../apps/backend/app/llm.py", line 735
    FALLBACK_MAX_TOKENS = 4096
    ^^^^^^^^^^^^^^^^^^^
IndentationError: expected an indented block after function definition on line 734

Root cause (introduced by #775)

git blame upstream/main -- apps/backend/app/llm.py shows the refactor in #775 was only partially applied:

In other words: the new signature was pasted on top, the function body was never moved, and the old definition was never deleted.

Type

  • Bug Fix
  • Feature Enhancement
  • Documentation Update
  • Code Refactoring
  • Other (please specify):

Proposed Changes

  • Remove the empty stub at app/llm.py:734 (keep FALLBACK_MAX_TOKENS = 4096, which get_safe_max_tokens depends on).
  • Update the real implementation at app/llm.py:782 to use the schema-aware signature def _appears_truncated(data: dict, schema_type: str = "resume") -> bool: so it matches both its body and its callers.

Screenshots / Code Snippets (if applicable)

Reproducer on main:

$ uv run app
Traceback (most recent call last):
  File ".../apps/backend/.venv/bin/app", line 4, in <module>
    from app.main import main
  File ".../apps/backend/app/main.py", line 21, in <module>
    from app.routers import config_router, enrichment_router, health_router, jobs_router, resumes_router
  File ".../apps/backend/app/routers/__init__.py", line 3, in <module>
    from app.routers.config import router as config_router
  File ".../apps/backend/app/routers/config.py", line 10, in <module>
    from app.llm import check_llm_health, LLMConfig, resolve_api_key
  File ".../apps/backend/app/llm.py", line 735
    FALLBACK_MAX_TOKENS = 4096
    ^^^^^^^^^^^^^^^^^^^
IndentationError: expected an indented block after function definition on line 734

How to Test

  1. uv run python -c "from app.llm import _appears_truncated; print('ok')" -> prints ok (no IndentationError).
  2. uv run pytest tests/unit/test_llm.py::TestAppearsTruncated -q -> 13/13 passing
  3. uv run pytest -q -> 179 passing. One pre-existing failure unrelated to this PR remains.
  4. uv run app -> backend boots without IndentationError.

Checklist

  • The code compiles successfully without any errors or warnings
  • The changes have been tested and verified
  • The documentation has been updated (if applicable)
  • The changes follow the project's coding guidelines and best practices
  • The commit messages are descriptive and follow the project's guidelines
  • All tests (if applicable) pass successfully
  • [] This pull request has been linked to the related issue (if applicable)

Additional Information

While verifying this fix locally I had to pin python-dotenv back to 1.0.1 because 1.2.2 (the current pyproject.toml pin from #761) conflicts with litellm's ==1.0.1 requirement, so uv sync itself fails. The dependency fix is in #780.


Summary by cubic

Fixes backend import crash by removing a duplicate _appears_truncated stub and aligning the function signature with callers. Restores uv run app startup by resolving the IndentationError.

  • Bug Fixes
    • Removed the empty _appears_truncated definition; kept FALLBACK_MAX_TOKENS = 4096.
    • Updated _appears_truncated to def _appears_truncated(data: dict, schema_type: str = "resume") -> bool: to match usage.

Written for commit 820dc37. Summary will update on new commits.

Copilot AI review requested due to automatic review settings May 4, 2026 06:58
Copy link
Copy Markdown
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.

No issues found across 1 file

Copy link
Copy Markdown

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

Fixes a backend-breaking regression in apps/backend/app/llm.py where an incomplete duplicate _appears_truncated definition caused an IndentationError at import time, preventing the backend from starting.

Changes:

  • Remove the stray _appears_truncated(...) stub that left FALLBACK_MAX_TOKENS = 4096 incorrectly positioned and triggered IndentationError.
  • Update the actual _appears_truncated implementation to accept schema_type: str = "resume" to match its internal logic and call sites.

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

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