Skip to content

Fix: Standardize /generate_gform response shape for web and extension UIs#570

Open
PunyaGowdagd66 wants to merge 1 commit intoAOSSIE-Org:mainfrom
PunyaGowdagd66:fix-gform-response
Open

Fix: Standardize /generate_gform response shape for web and extension UIs#570
PunyaGowdagd66 wants to merge 1 commit intoAOSSIE-Org:mainfrom
PunyaGowdagd66:fix-gform-response

Conversation

@PunyaGowdagd66
Copy link
Copy Markdown

@PunyaGowdagd66 PunyaGowdagd66 commented Mar 14, 2026

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

    • Form generation endpoint now returns both a shareable form link and an edit link in a single structured response.
  • Changes

    • Automatic browser tab opening behavior has been removed from the form generation process.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 14, 2026

📝 Walkthrough

Walkthrough

The /generate_gform endpoint was refactored to return both responder and edit URLs in a single JSON response with explicit 200 status, removing the browser tab opening side-effect.

Changes

Cohort / File(s) Summary
Generate Form Flow
backend/server.py
Reworked generate_gform() to return a JSON object with form_link and edit_link fields instead of a single edit URL, and removed the browser tab opening behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A form endpoint, dressed up anew,
Returns both links for me and you,
No browser pop-ups, just clean JSON—
A cleaner response to build upon!
Two paths instead of one, you see,
Refactored with simplicity. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: standardizing the /generate_gform endpoint response shape to support both web and extension UIs, which directly aligns with the PR's core objective of fixing a response shape mismatch.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ebfff5ce-e50d-4627-ab00-29364501edba

📥 Commits

Reviewing files that changed from the base of the PR and between fc3bf1a and 3a1b1a1.

📒 Files selected for processing (1)
  • backend/server.py

Comment thread backend/server.py
Comment on lines +362 to +368
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant