You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We reviewed changes in 9d1323c...f634b03 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
The reason will be displayed to describe this comment to others. Learn more.
Dangerous default value [] as argument
Do not use a mutable like list or dictionary as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
The reason will be displayed to describe this comment to others. Learn more.
Dangerous default value {} as argument
Do not use a mutable like list or dictionary as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
The reason will be displayed to describe this comment to others. Learn more.
Dangerous default value [] as argument
Do not use a mutable like list or dictionary as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
The reason will be displayed to describe this comment to others. Learn more.
Dangerous default value {} as argument
Do not use a mutable like list or dictionary as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
The reason will be displayed to describe this comment to others. Learn more.
Dangerous default value [] as argument
Do not use a mutable like list or dictionary as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
The reason will be displayed to describe this comment to others. Learn more.
Method doesn't use the class instance and could be converted into a static method
The method doesn't use its bound instance. Decorate this method with @staticmethod decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods here.
The reason will be displayed to describe this comment to others. Learn more.
Bare `except` hides unexpected runtime failures
remove_product catches every exception, not just missing keys. Real defects in _products handling get swallowed, and callers receive None, obscuring operational failures.
Catch KeyError explicitly, and log unexpected exceptions with logger.exception before re-raising.
The reason will be displayed to describe this comment to others. Learn more.
Bare `except` suppresses export data errors
export_snapshot catches all exceptions and continues. Corrupted product data can silently drop rows, producing incomplete exports and hidden data-quality defects.
Catch specific expected exceptions, and for unknown exceptions use logger.exception and fail fast or collect explicit error results.
The reason will be displayed to describe this comment to others. Learn more.
`%` string formatting enables SQL injection in `recipient` filter
get_unread builds query using % interpolation, then passes it to conn.execute. Attackers controlling recipient can alter WHERE logic and read other users’ notifications.
Replace string interpolation with a parameterized statement using ? placeholders and pass (recipient,) separately.
The reason will be displayed to describe this comment to others. Learn more.
`except:` swallows database errors and hides failure causes
A bare except: in get_unread suppresses root-cause visibility and masks runtime faults as normal empty results. This can silently break alert delivery logic and delay incident diagnosis.
Catch sqlite3.Error explicitly, log the exception details, and re-raise or return a typed error path distinct from valid empty results.
The reason will be displayed to describe this comment to others. Learn more.
Mutable `{} ` default risks shared state bugs
Using filters: dict[str, Any] = {} creates one shared dictionary for every invocation. If later code mutates it, callers can influence each other and produce hard-to-reproduce failures.
Replace with filters: Optional[dict[str, Any]] = None and initialize filters = {} inside the method
The reason will be displayed to describe this comment to others. Learn more.
`csv.DictWriter` raises on rows with extra keys
Using first-row keys as a fixed schema can crash exports when later rows have additional fields. One malformed or richer record stops the entire report and loses output.
Build fieldnames as the union of keys across all records, or configure extrasaction='ignore' to tolerate extra keys
The reason will be displayed to describe this comment to others. Learn more.
Unsanitized `writer.writerow` allows spreadsheet formula execution
writer.writerow(record) emits untrusted cell values directly into CSV output. If user-controlled text starts with formula prefixes, spreadsheet clients can execute payloads, enabling data exfiltration or command invocation via client integrations.
Sanitize each string cell before writing by prefixing dangerous leading characters with a quote or tab
The implementation ignores group_by, so grouped summaries are never produced despite API and docstring promises. Consumers can trust incorrect results and make wrong inventory decisions.
Implement grouping logic when group_by is provided, returning stats keyed by group value; otherwise keep current global aggregate behavior
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
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.
No description provided.