Skip to content

fix(links): use pydash.get + decode body to fix analyze chain (CON-573)#184

Merged
pavanputhra merged 1 commit into
mainfrom
pavankumar/con-573-fix-analyze-link
May 26, 2026
Merged

fix(links): use pydash.get + decode body to fix analyze chain (CON-573)#184
pavanputhra merged 1 commit into
mainfrom
pavankumar/con-573-fix-analyze-link

Conversation

@pavanputhra
Copy link
Copy Markdown
Contributor

Summary

  • Closes CON-573TypeError: string indices must be integers, not 'str' thrown from the analyze link's navigate_dict, killing the chain and DLQing vCons.
  • Root cause: navigate_dict was copy-pasted into 5 link modules with key in current traversal. When an intermediate step landed on a JSON-encoded body string (the spec-current shape after fix(vcon): decode body per spec on read, canonicalize on write #182), key in current did a substring check, passed, and the next current[key] raised on the string-indexed access.
  • Replaced all 5 in-house copies with pydash.get (already a core dep — pydash>=7.0.7 in pyproject.toml). pydash.get handles every edge case we relied on (None input, missing key, non-dict mid-path, list-index-via-dot) and returns None cleanly instead of raising.
  • Additionally wrapped source with Vcon.with_decoded_body(source) in analyze and analyze_and_label so a dotted text_location like body.paragraphs.transcript can still drill through a JSON-encoded body — check_and_tag and detect_engagement already do this; analyze/analyze_and_label had silently broken after fix(vcon): decode body per spec on read, canonicalize on write #182.
  • Dropped 4 duplicate test_navigate_dict* blocks (testing in-house code that no longer exists). Kept one TestPydashGetContract::test_returns_none_when_midpath_is_non_dict in test_analyze.py that pins the CON-573 behaviour we depend on.
  • Net diff: +52 / -131 across 9 files.

Side-effect (positive)

5 tests that were already failing on main with the same CON-573 TypeError now pass:

  • conserver/tests/test_link_metrics.py::TestAnalyzeMetrics::test_success_records_analysis_time
  • conserver/tests/test_link_metrics.py::TestAnalyzeMetrics::test_failure_increments_counter
  • conserver/tests/test_link_metrics.py::TestAnalyzeAndLabelMetrics::test_success_records_labels_added
  • conserver/tests/test_link_metrics.py::TestAnalyzeAndLabelMetrics::test_success_records_analysis_time
  • conserver/tests/test_link_metrics.py::TestAnalyzeAndLabelMetrics::test_failure_increments_counter

Plus the 6 analyze_and_label/tests/test_analyze_and_label.py::test_run_* tests that were silently broken on main for the same reason.

The remaining test failures on this branch (TestCheckAndTagMetrics x3, TestOpenAITranscribeMetrics x2, groq_whisper::test_get_transcription) all pre-exist on main and are unrelated to this change.

Test plan

  • pytest conserver/links/{analyze,analyze_and_label,check_and_tag,detect_engagement,analyze_vcon}/38 passed, 10 skipped, 0 failures
  • Reproduced the original TypeError against the pre-fix navigate_dict in a one-liner and confirmed the new code returns None instead
  • Wider pytest conserver/ sweep — no new failures introduced
  • Deploy to test env and confirm the original DLQ'd vCons re-process cleanly

The in-house navigate_dict, copy-pasted into five link modules, used
`key in current` for traversal — which on a non-dict (e.g. an analysis
whose body is a JSON-encoded string after #182) does a substring check
and then crashes with TypeError on `current[key]`.

Replace all five copies with pydash.get (already a core dep), and in
analyze + analyze_and_label also wrap source with Vcon.with_decoded_body
so a dotted text_location can still drill through a JSON-encoded body —
matching what check_and_tag and detect_engagement already do.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pavanputhra pavanputhra merged commit 123dde9 into main May 26, 2026
1 check failed
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