Fix: Standardize /generate_gform response shape for web and extension UIs#570
Fix: Standardize /generate_gform response shape for web and extension UIs#570PunyaGowdagd66 wants to merge 1 commit intoAOSSIE-Org:mainfrom
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/server.py`:
- Around line 362-368: The current handler builds responder_url and edit_url
from result without validating them, which can return null or raise on missing
formId; update the logic that computes responder_url and edit_url to (1) use
result.get("formId") and result.get("responderUri") safely, (2) verify
responder_url is truthy and looks like a URL (e.g., starts with "http") and that
form_id is present before constructing edit_url, and (3) if validation fails
return a non-200 JSON error response (with an appropriate status like 400)
instead of returning the broken payload; adjust the branch that currently
returns jsonify({"form_link": responder_url, "edit_link": edit_url}), 200 to
perform these checks and return an error when invalid.
| responder_url = result.get("responderUri") | ||
| edit_url = "https://docs.google.com/forms/d/" + result["formId"] + "/edit" | ||
|
|
||
| return jsonify({ | ||
| "form_link": responder_url, | ||
| "edit_link": edit_url | ||
| }), 200 |
There was a problem hiding this comment.
Validate links before returning HTTP 200.
At Line 362 and Line 363, the code can return a success response with an invalid payload (form_link: null) or raise on missing formId. This breaks the new response contract for clients expecting usable URLs.
Proposed fix
- responder_url = result.get("responderUri")
- edit_url = "https://docs.google.com/forms/d/" + result["formId"] + "/edit"
-
- return jsonify({
- "form_link": responder_url,
- "edit_link": edit_url
- }), 200
+ form_id = result.get("formId")
+ responder_url = result.get("responderUri")
+ if not form_id or not responder_url:
+ return jsonify({"error": "Failed to generate Google Form links"}), 502
+
+ edit_url = f"https://docs.google.com/forms/d/{form_id}/edit"
+ return jsonify({
+ "form_link": responder_url,
+ "edit_link": edit_url
+ }), 200🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@backend/server.py` around lines 362 - 368, The current handler builds
responder_url and edit_url from result without validating them, which can return
null or raise on missing formId; update the logic that computes responder_url
and edit_url to (1) use result.get("formId") and result.get("responderUri")
safely, (2) verify responder_url is truthy and looks like a URL (e.g., starts
with "http") and that form_id is present before constructing edit_url, and (3)
if validation fails return a non-200 JSON error response (with an appropriate
status like 400) instead of returning the broken payload; adjust the branch that
currently returns jsonify({"form_link": responder_url, "edit_link": edit_url}),
200 to perform these checks and return an error when invalid.
This PR fixes the response shape mismatch in the /generate_gform endpoint.
Previously the backend returned a raw string containing responderUri, while the frontend expected a JSON object with form_link.
This change standardizes the API response to return:
{
"form_link": responder_url,
"edit_link": edit_url
}
This ensures both the web app and browser extension can correctly open the generated Google Form.
Summary by CodeRabbit
New Features
Changes