Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modifies the error handling in the get_custom_metrics function to preserve plain-string custom metric values instead of discarding them when JSON parsing fails. Previously, when a ValueError occurred during JSON parsing, the metric was skipped entirely with a warning logged. Now, the code keeps the original string value as-is.
- Changed ValueError exception handling from logging a warning and skipping the metric to keeping the value as a plain string
- Added an inline comment explaining the new behavior
Comments suppressed due to low confidence (1)
HTTPArchive/httparchive.py:140
- Inconsistent error handling: The ValueError exception now keeps the value as a plain string (using pass), but the RecursionError exception still skips the metric entirely (using continue). Consider whether RecursionError should also keep the original string value for consistency, or if there's a specific reason to treat these errors differently.
# Value is a plain string, not JSON-encoded. Keep it as-is.
pass
except RecursionError:
logging.warning(
"RecursionError: Unable to parse custom metric %s as JSON for %s",
metric,
wptid,
)
continue
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request makes a minor change to the error handling in the
get_custom_metricsfunction. Specifically, it no longer logs a warning when a custom metric value cannot be parsed as JSON and instead simply keeps the value as a plain string.