Conversation
There was a problem hiding this comment.
Pull Request Overview
Refactor updates the InvalidFormatError message in parse_parts to include the full input string rather than a truncated preview. This changes what gets surfaced/logged when mismatched or nested masked tags are detected.
- Expand error detail to include full string s
- Remove prior truncation and ellipsis from the error message
| full_matches = list(TAG_FULL_PATTERN.finditer(s)) | ||
| if not (len(open_matches) == len(end_matches) == len(full_matches)): | ||
| raise InvalidFormatError(f"Mismatched or nested masked tags in {s[:50]}...") | ||
| raise InvalidFormatError(f"Mismatched or nested masked tags in {s}") |
There was a problem hiding this comment.
Including the full input string in the error can leak sensitive or user-provided content if exceptions are logged or surfaced. Prefer emitting a bounded preview and indicate truncation, e.g., limit to 50–100 chars and add '...' when longer.
| raise InvalidFormatError(f"Mismatched or nested masked tags in {s}") | |
| preview = s[:100] + ("..." if len(s) > 100 else "") | |
| raise InvalidFormatError(f"Mismatched or nested masked tags in input (preview: '{preview}')") |
| full_matches = list(TAG_FULL_PATTERN.finditer(s)) | ||
| if not (len(open_matches) == len(end_matches) == len(full_matches)): | ||
| raise InvalidFormatError(f"Mismatched or nested masked tags in {s[:50]}...") | ||
| raise InvalidFormatError(f"Mismatched or nested masked tags in {s}") |
There was a problem hiding this comment.
Formatting the entire input string into the exception can significantly bloat log lines and allocations for very large inputs. Use a concise preview (e.g., s[:50] with an ellipsis when longer) to keep error messages lightweight.
| raise InvalidFormatError(f"Mismatched or nested masked tags in {s}") | |
| preview = s[:50] + ("..." if len(s) > 50 else "") | |
| raise InvalidFormatError(f"Mismatched or nested masked tags in input: '{preview}'") |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
No description provided.