Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions airbyte_cdk/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def airbyte_message_to_string(airbyte_message: AirbyteMessage) -> str:
f"There was an error during the serialization of an AirbyteMessage: `{exception}`. This might impact the sync performances."
)
_HAS_LOGGED_FOR_SERIALIZATION_ERROR = True
print(airbyte_message.record.data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Fix the potential AttributeError when accessing record data.

The mypy error is correct - airbyte_message.record could be None, which would cause a runtime error when accessing .data. Since this is for debugging PayPal transactions, maybe we could add a null check? wdyt?

-            print(airbyte_message.record.data)
+            if airbyte_message.record is not None:
+                print(f"Debug - Record data: {airbyte_message.record.data}")
+            else:
+                print("Debug - Record is None")

Also, since this is debug code that prints to stdout, it might interfere with the normal Airbyte message output. Would using logger.debug() instead be better for debugging purposes? That way it respects the logging configuration and won't mix with the protocol output.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(airbyte_message.record.data)
if airbyte_message.record is not None:
print(f"Debug - Record data: {airbyte_message.record.data}")
else:
print("Debug - Record is None")
🧰 Tools
🪛 GitHub Actions: Linters

[error] 342-342: mypy error: Item "None" of "Any | None" has no attribute "data" [union-attr]

🤖 Prompt for AI Agents
In airbyte_cdk/entrypoint.py at line 342, the code accesses
airbyte_message.record.data without checking if record is None, risking an
AttributeError. Add a null check to ensure airbyte_message.record is not None
before accessing .data. Also, replace the print statement with a logger.debug
call to avoid mixing debug output with normal Airbyte message output and respect
logging configuration.

return json.dumps(serialized_message)

@classmethod
Expand Down
Loading