Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
sanitize nul char in totp content (#2186)
Shuchang Zhenge6c95cc987e1
diff --git a/skyvern/forge/sdk/schemas/totp_codes.py b/skyvern/forge/sdk/schemas/totp_codes.pyindex 392fb34f2..8acdddbd5 100644--- a/skyvern/forge/sdk/schemas/totp_codes.py+++ b/skyvern/forge/sdk/schemas/totp_codes.py@@ -1,6 +1,8 @@from datetime import datetime-from pydantic import BaseModel, ConfigDict+from pydantic import BaseModel, ConfigDict, field_validator++from skyvern.forge.sdk.utils.sanitization import sanitize_postgres_textclass TOTPCodeBase(BaseModel):@@ -19,6 +21,12 @@ class TOTPCodeCreate(TOTPCodeBase):totp_identifier: strcontent: str+ @field_validator("content")+ @classmethod+ def sanitize_content(cls, value: str) -> str:+ """Remove NUL (0x00) bytes from content to avoid PostgreSQL DataError."""+ return sanitize_postgres_text(value)+class TOTPCode(TOTPCodeCreate):totp_code_id: strdiff --git a/skyvern/forge/sdk/utils/sanitization.py b/skyvern/forge/sdk/utils/sanitization.pynew file mode 100644index 000000000..9f3e91a2a--- /dev/null+++ b/skyvern/forge/sdk/utils/sanitization.py@@ -0,0 +1,18 @@+"""+Utility functions for sanitizing content before storing in the database.+"""+++def sanitize_postgres_text(text: str) -> str:+ """+ Sanitize text to be stored in PostgreSQL by removing NUL bytes.++ PostgreSQL text fields cannot contain NUL (0x00) bytes, so we remove them.++ Args:+ text: The text to sanitize++ Returns:+ The sanitized text without NUL bytes+ """+ return text.replace("\0", "")