fix(links): use pydash.get + decode body to fix analyze chain (CON-573)#184
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeError: string indices must be integers, not 'str'thrown from theanalyzelink'snavigate_dict, killing the chain and DLQing vCons.navigate_dictwas copy-pasted into 5 link modules withkey in currenttraversal. When an intermediate step landed on a JSON-encodedbodystring (the spec-current shape after fix(vcon): decode body per spec on read, canonicalize on write #182),key in currentdid a substring check, passed, and the nextcurrent[key]raised on the string-indexed access.pydash.get(already a core dep —pydash>=7.0.7inpyproject.toml).pydash.gethandles every edge case we relied on (None input, missing key, non-dict mid-path, list-index-via-dot) and returnsNonecleanly instead of raising.sourcewithVcon.with_decoded_body(source)inanalyzeandanalyze_and_labelso a dottedtext_locationlikebody.paragraphs.transcriptcan still drill through a JSON-encoded body —check_and_taganddetect_engagementalready do this;analyze/analyze_and_labelhad silently broken after fix(vcon): decode body per spec on read, canonicalize on write #182.test_navigate_dict*blocks (testing in-house code that no longer exists). Kept oneTestPydashGetContract::test_returns_none_when_midpath_is_non_dictintest_analyze.pythat pins the CON-573 behaviour we depend on.Side-effect (positive)
5 tests that were already failing on
mainwith the same CON-573 TypeError now pass:conserver/tests/test_link_metrics.py::TestAnalyzeMetrics::test_success_records_analysis_timeconserver/tests/test_link_metrics.py::TestAnalyzeMetrics::test_failure_increments_counterconserver/tests/test_link_metrics.py::TestAnalyzeAndLabelMetrics::test_success_records_labels_addedconserver/tests/test_link_metrics.py::TestAnalyzeAndLabelMetrics::test_success_records_analysis_timeconserver/tests/test_link_metrics.py::TestAnalyzeAndLabelMetrics::test_failure_increments_counterPlus the 6
analyze_and_label/tests/test_analyze_and_label.py::test_run_*tests that were silently broken onmainfor the same reason.The remaining test failures on this branch (
TestCheckAndTagMetricsx3,TestOpenAITranscribeMetricsx2,groq_whisper::test_get_transcription) all pre-exist onmainand 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 failuresTypeErroragainst the pre-fixnavigate_dictin a one-liner and confirmed the new code returnsNoneinsteadpytest conserver/sweep — no new failures introduced