Skip to content

Add app-frontend integration scripts - #11

Merged
itsryanarmani merged 8 commits into
mainfrom
integration-scripts-batch
Aug 24, 2026
Merged

itsryanarmani merged 8 commits into
mainfrom
integration-scripts-batch

Conversation

@itsryanarmani

Copy link
Copy Markdown
Owner

Per-marketplace command playbook + smallest-real-wiring example for Canva, Figma, Shopify, Notion, WordPress, Framer, Google Workspace, Raycast. Pairs with the integration skills in pooriaarab/skills. Adobe Express to follow.

itsryanarmani and others added 8 commits August 23, 2026 12:23
Per-marketplace command playbook (README) + smallest-real-wiring example
for Canva, Figma, Shopify, Notion, WordPress, Framer, Google Workspace,
Raycast. Pairs with the integration skills in pooriaarab/skills.
- notion-integration/example.ts: reject Status properties that are
  neither status nor select instead of silently treating them as
  select (produces an invalid API filter); write the Post ID/URL
  idempotency marker before the Status update so a failed status
  write can't cause the next sync to re-post the same row.
- wordpress-plugin/example.php: skip save_post once a remote post id
  is recorded, so editing an already-published post no longer creates
  a duplicate resource on every save; wp_unslash the settings API
  input before sanitizing so keys with quotes/backslashes survive.
- notion-integration/example.ts: loop start_cursor/has_more so >100
  "Ready" rows all sync instead of only the first page.
- wordpress-plugin/example.php: restrict save_post to the 'post' type
  (it was firing for every published post type, including Pages) and
  flag a 2xx response with no id instead of leaving the idempotency
  guard unset, which let every later save re-POST a duplicate.
council-findings.md and pr.diff were local working files from the
review process, not intended for the repo.
- canva-app: replace Adobe Express's addOnUISdk/createRenditions (copy-paste
  leftover) with Canva's real @canva/design requestExport API.
- framer-plugin: fix the npm package name (framer-plugin, not @framer/plugin)
  in the README and example import.
- notion-integration: keep the created post id across a failed write-back so
  a transient Notion API failure can't cause a duplicate repost, validate the
  API response has an id before treating the row as synced, and clear stale
  Error text on a later success.
- google-workspace-addon: catch UrlFetchApp connection-level exceptions
  (muteHttpExceptions only covers HTTP status errors) so a network failure
  shows a notification instead of a generic Apps Script error.
canva-app, adobe-express-addon, figma-plugin, and framer-plugin all called
/posts with mediaIds: [media.id] without checking that /media returned a
usable id, so a malformed 2xx response silently produced a broken post.
canva-app also skipped the HTTP status check on the exported blob fetch.
Notion sync could leave a row stuck in Ready forever if the Post ID write
succeeded but the following Status write failed (e.g. transient 429) since
the idempotency guard would skip it on every later run; now it retries just
the Status write for rows that already have a Post ID.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ion error write

- WordPress: drop the current_user_can() gate on the publish sync path — WP-Cron
  publishing a scheduled post runs with no logged-in user, so the check was always
  false and silently skipped the API push for every scheduled post.
- WordPress: treat a transport-level WP_Error (timeout/DNS/TLS) like the missing-id
  case (_needs_attention) instead of leaving it retryable, since we can't tell
  whether the remote already processed the request.
- Figma: add an in-flight guard around the "share" handler so two rapid share
  messages can't run concurrently and create duplicate remote posts.
- Notion: isolate the catch-path Post ID write in its own try so a failing Error
  write can't leave an uncaught rejection that aborts the sync run and drops the
  idempotency marker, which would duplicate the post on the next run.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Council review synthesized below. Verified each claim against the surrounding code (not just the hunks) before posting. No fixes pushed this cycle — push access is disabled for this run (3 prior automated fix cycles already landed against this exact area of notion-integration/example.ts), so the two confirmed Major findings below are flagged for a human rather than patched again.

Confirmed (posted inline)

  1. notion-integration/example.ts — uncaught rejection can abort syncOnce mid-loop. In the "Post ID already present, retry Status" branch, the catch that writes the Error property is not itself wrapped in try/catch. If that write throws (429, network blip), the rejection propagates out of the for loop and aborts the whole sync run, leaving every later Ready row unsynced for that run. This is the exact failure pattern already fixed in the other catch block lower in the same function (commit c9fb344) — just not applied here.
  2. notion-integration/example.ts — duplicate remote post when the create call times out or returns 2xx without a usable id. In both cases post?.id is falsy, so the code only writes the Error field and never touches Status or Post ID. The row stays Ready, so the next syncOnce matches it again via the Ready filter and calls /posts a second time, creating a duplicate remote resource. The WordPress version in this same PR has an explicit _your_product_needs_attention guard for this identical failure mode; the Notion version has no equivalent anti-retry marker.

Rejected (did not survive verification)

  • GPT-5.6, google-workspace-addon/example.gs:38 — claimed e.formInput.apiKey fails because inputs only land under e.commonEventObject.formInputs. Not true for Google Workspace Add-ons (non-Chat surfaces): both the legacy e.formInput/e.formInputs and e.commonEventObject.formInputs are populated on the action event object; only Chat apps are common-event-object-only. e.formInput.apiKey is the standard, widely-documented pattern.
  • GPT-5.6, adobe-express-addon/example.ts:41 — claimed a 204 response makes res.json() throw. The code's own contract requires media.id/post.id from the parsed body (if (!media?.id) throw ...), so a 204-with-no-body response would already violate the implied API contract this example assumes; not a concrete failure trigger for this code.

Rolled into summary as Minor (not pushed)

  • Gemini 3 Pro (performance), wordpress-plugin/example.php:73 — the save_post hook makes a synchronous API call, which blocks the editor save request. Real, but this is explicitly the "smallest real wiring" example, and moving to wp_schedule_single_event is a scope expansion beyond a bug fix.
  • Gemini 3 Pro (performance), notion-integration/example.ts:55 — buffering all paginated Notion rows into one array before processing could get memory-heavy on a database with thousands of Ready rows. Legitimate at scale; not a defect in normal example usage.
  • GPT-5.6 (correctness), wordpress-plugin/example.php:62 — two near-simultaneous save_post invocations for the same post could both pass the metadata guard before either persists an ID (TOCTOU), double-posting. Plausible but a narrow race requiring genuinely concurrent requests; fixing it properly needs an atomic per-post lock, which is more than this minimal example implements today.
🧑‍⚖️ Council
Model Lens Result
GPT-5.6 (Codex) correctness 1 confirmed (merged into Notion duplicate-post finding below), 2 rejected
Gemini 3 Pro performance 2 findings, rolled into summary as Minor
Kimi K3 security errored (provider quota exceeded) — no findings produced
Grok 4.5 maintainability 2 confirmed

} as never,
});
} catch (err) {
await notion.pages.update({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Major. This Error write isn't wrapped in its own try/catch, unlike the equivalent write in the create-post catch block further down (fixed in c9fb344). If this pages.update call throws (429, transient network error), the rejection is uncaught here and propagates out of the for loop, aborting syncOnce entirely — every later Ready row in this run goes unsynced with no error surfaced. Wrap it the same way the lower catch block does.

// A 2xx with no usable id means we can't tell whether a remote resource was
// created; don't persist "undefined" as the Post ID or the continue guard
// above would skip this row forever with no real remote link.
if (!post?.id) throw new Error("API response missing id");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Major. When postToApi throws before post is assigned (timeout/network) or returns 2xx without a usable id, the row falls through to the outer catch with post?.id falsy — so only Error gets written, Status stays Ready, and Post ID is never set. The next syncOnce run's Ready-filter query matches this row again and calls /posts a second time, creating a duplicate remote post. The WordPress example in this PR guards the identical case with _your_product_needs_attention; this Notion path has no equivalent anti-retry marker before the row can be reprocessed.

@itsryanarmani
itsryanarmani merged commit 2744b75 into main Aug 24, 2026
1 check passed
@itsryanarmani
itsryanarmani deleted the integration-scripts-batch branch August 24, 2026 06:30
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