Fix comment issues with regression introduced in 2.2.15 #129
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.
Fix GitLab MR comment handling causing
AttributeError: 'str' object has no attribute 'id'This bug was preventing the GitLab integration from properly updating existing Socket Security comments on merge requests, causing the CLI to crash with an AttributeError when trying to access the
.idattribute on a string instead of a Comment object.Root Cause
In commit
cc45ff4(v2.2.15), the GitLab comment retrieval logic was changed fromcomments.get("overview")tocomments.get("overview", ""), which introduced a breaking change:.get()returnedNone.get()returned an empty string""The conditional check
if existing_overview_comment is not None:now evaluates toTruefor empty strings (since"" is not NoneisTrue), causing the code to attempt updating a non-existent comment by accessing.idon a string, resulting inAttributeError: 'str' object has no attribute 'id'.Fix
Reverted the GitLab comment retrieval logic to the working v2.0.2 behavior by removing the default empty string parameters:
comments.get("overview", "")back tocomments.get("overview")comments.get("security", "")back tocomments.get("security")remove_comment_alertsmethodThis ensures that when no existing comments are found, the variables are
None, making theis not Nonechecks work correctly:None: New comments are posted (correct behavior)Commentobject exists: Existing comments are updated via.idaccess (correct behavior)Added explanatory comments about Python's type narrowing to maintain type safety without reintroducing the bug.
Public Changelog