Skip to content

Commit d727dcc

Browse files
committed
feat(config): auto-truncate commit messages over 200 chars
The --commit-message flag passes its value directly into the API request URL as a query parameter with no length limit. AI-generated commit messages and the common CI pattern of concatenating $BUILDKITE_BUILD_NUMBER + $BUILDKITE_MESSAGE can easily exceed URL length limits, producing HTTP 413 errors. The 413 originates from an infrastructure-layer URL length limit (nginx/Cloudflare), not application-level validation -- confirmed via inspection of the Socket API route handler, which has no constraint on commit_message (unlike committers, which enforces <= 200 chars and returns a clean 400). 200 chars chosen as a conservative defensive ceiling given URL encoding can 2-3x raw character count. No customer should ever want a 2000-character commit message in their scan metadata. A backend-side validation (returning 400 instead of 413) is filed as a follow-on for the depscan API team. Motivated by customer incidents (Plaid). Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent be20a43 commit d727dcc

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

socketsecurity/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
177177
if commit_message and commit_message.startswith('"') and commit_message.endswith('"'):
178178
commit_message = commit_message[1:-1]
179179

180+
# Truncate to avoid 413s from oversized URL query parameters.
181+
# The API has no application-layer length validation on commit_message;
182+
# the 413 originates from an infrastructure-layer URL length limit
183+
# (nginx/Cloudflare). 200 chars chosen as a conservative ceiling given
184+
# URL encoding can 2-3x raw character count.
185+
MAX_COMMIT_MESSAGE_LENGTH = 200
186+
if commit_message and len(commit_message) > MAX_COMMIT_MESSAGE_LENGTH:
187+
logging.debug(
188+
f"commit_message truncated from {len(commit_message)} to "
189+
f"{MAX_COMMIT_MESSAGE_LENGTH} characters to avoid API request size limits"
190+
)
191+
commit_message = commit_message[:MAX_COMMIT_MESSAGE_LENGTH]
192+
180193
config_args = {
181194
'api_token': api_token,
182195
'repo': args.repo,

0 commit comments

Comments
 (0)