feat: MetaflowTaggingError formatting and add test coverage for tagging_util#3165
feat: MetaflowTaggingError formatting and add test coverage for tagging_util#3165Vaishnav88sk wants to merge 2 commits into
Conversation
The validate_tag function was passing arguments incorrectly to MetaflowTaggingError, causing str() to fail when the exception was rendered. This also adds comprehensive test coverage for is_utf8_encodable, is_utf8_decodable, validate_tag, and validate_tags including edge cases for type validation, length limits, and tag set size constraints. Fixes error message formatting for non-string tag types.
Greptile SummaryThis PR fixes a genuine bug in Confidence Score: 5/5Safe to merge — minimal, targeted fix with solid test coverage and no regressions. The only change to production code is a one-line fix that correctly pre-evaluates a format string. All 30 new tests are logically correct. No security, data, or runtime concerns. No files require special attention. Important Files Changed
Reviews (4): Last reviewed commit: "Merge branch 'master' into feat/add-tagg..." | Re-trigger Greptile |
00785c5 to
0599df1
Compare
The validate_tag function was passing arguments incorrectly to MetaflowTaggingError, causing str() to fail when the exception was rendered. This also adds comprehensive test coverage for is_utf8_encodable, is_utf8_decodable, validate_tag, and validate_tags including edge cases for type validation, length limits, and tag set size constraints.
Fixes error message formatting for non-string tag types.
PR Type
Summary
Fix error message formatting bug in
validate_tagand add comprehensive unit test coverage fortagging_util.py(30 tests).Issue
Fixes #3162
Context / Motivation
The
validate_tagfunction passed two positional arguments toMetaflowTaggingError, but the exception class expectsmsg,lineno,source_fileas positional args. This causedTypeError: %d format: a real number is required, not strwhen rendering the exception for non-string tag types.Additionally,
tagging_util.pyhad zero test coverage despite beingcritical infrastructure for run/step tagging validation.
Reproduction
Runtime:
Commands to run:
# paste exact commandsWhere evidence shows up:
Before (error / log snippet)
After (evidence that fix works)
Root Cause
Changes Made
MetaflowTaggingErrorcall to use string formatting instead of multiple positional argumentsis_utf8_encodable/is_utf8_decodablefunctionsvalidate_tagwith valid inputs and all error conditionsvalidate_tagsincluding tag set size limits and remediation logicWhy This Fix Is Correct
Failure Modes Considered
Tests
Non-Goals
AI Tool Usage
For formatting