Skip to content

chore: radiooptionblockupdate modern#8983

Merged
mikeallisonJS merged 11 commits intomainfrom
26-00-MA-chore-radiooptionblockupdate-modern
Apr 9, 2026
Merged

chore: radiooptionblockupdate modern#8983
mikeallisonJS merged 11 commits intomainfrom
26-00-MA-chore-radiooptionblockupdate-modern

Conversation

@mikeallisonJS
Copy link
Copy Markdown
Collaborator

@mikeallisonJS mikeallisonJS commented Apr 8, 2026

Summary by CodeRabbit

New Features

  • Added new mutation operations for creating and updating radio option blocks and image blocks, and updating icon blocks to enhance block management capabilities.

Tests

  • Added comprehensive test suite for radio option block updates, including authorization validation and error handling.

@mikeallisonJS mikeallisonJS requested a review from csiyang April 8, 2026 20:07
@mikeallisonJS mikeallisonJS self-assigned this Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 41fc73a6-1a99-46c5-9396-46c713f22fef

📥 Commits

Reviewing files that changed from the base of the PR and between 0f11d93 and 698fc0b.

📒 Files selected for processing (1)
  • apis/api-gateway/schema.graphql

Walkthrough

The pull request migrates radio option block mutations from the api-journeys graph to api-journeys-modern. This includes updating the API gateway routing, extending the modern service's schema with new mutation fields, and implementing the radioOptionBlockUpdate mutation resolver with authentication, authorization checks, and database transaction handling.

Changes

Cohort / File(s) Summary
API Gateway Routing
apis/api-gateway/schema.graphql
Routed radioOptionBlockUpdate mutation from API_JOURNEYS to API_JOURNEYS_MODERN graph with override: "api-journeys" directive.
Modern Journeys Schema
apis/api-journeys-modern/schema.graphql
Added 5 new mutation fields (iconBlockUpdate, imageBlockCreate, imageBlockUpdate, radioOptionBlockCreate, radioOptionBlockUpdate), each with @override(from: "api-journeys") directive.
Radio Option Block Implementation
apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.ts, radioOptionBlockUpdate.mutation.spec.ts
Implemented radioOptionBlockUpdate mutation with authentication, authorization enforcement via ACL checks, and Prisma transaction handling; includes comprehensive test suite covering authorization, unauthorized access, and partial input scenarios.
Module Registration
apis/api-journeys-modern/src/schema/block/radioOption/index.ts
Added imports for new mutation definition files (radioOptionBlockCreate.mutation, radioOptionBlockUpdate.mutation).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • csiyang
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title is partially related to the changeset but lacks clarity and specificity; it abbreviates 'radioOptionBlockUpdate' inconsistently and doesn't clearly convey that mutations are being migrated to the modern API. Consider using a more descriptive title such as 'chore: migrate radioOptionBlockUpdate mutation to api-journeys-modern' to better convey the primary objective of the change.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 26-00-MA-chore-radiooptionblockupdate-modern

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.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 8, 2026

View your CI Pipeline Execution ↗ for commit 698fc0b

Command Status Duration Result
nx affected --target=subgraph-check --base=2414... ✅ Succeeded 4s View ↗
nx affected --target=extract-translations --bas... ✅ Succeeded 3s View ↗
nx affected --target=lint --base=241410d816f52d... ✅ Succeeded 14s View ↗
nx affected --target=type-check --base=241410d8... ✅ Succeeded 26s View ↗
nx run-many --target=codegen --all --parallel=3 ✅ Succeeded 2s View ↗
nx run-many --target=prisma-generate --all --pa... ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-09 22:27:40 UTC

@github-actions github-actions Bot temporarily deployed to Preview - videos-admin April 8, 2026 20:09 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys April 8, 2026 20:09 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 8, 2026 20:09 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch April 8, 2026 20:09 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - resources April 8, 2026 20:09 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 8, 2026 20:09 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - short-links April 8, 2026 20:09 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
short-links ✅ Ready short-links preview Fri Apr 10 10:20:51 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Fri Apr 10 10:20:54 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
player ✅ Ready player preview Fri Apr 10 10:20:24 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Fri Apr 10 10:21:03 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
resources ✅ Ready resources preview Fri Apr 10 10:21:02 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Fri Apr 10 10:21:28 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Fri Apr 10 10:21:20 NZST 2026

Copy link
Copy Markdown
Contributor

@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: 9

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.cursor/skills/create-api-journeys-override/SKILL.md:
- Around line 314-319: The test invocation in the docs for api-journeys-modern
runs tests in parallel; update the test command to run sequentially by adding
the Jest flag --runInBand to the existing command shown with nx test
api-journeys-modern --testPathPattern="<fieldName>" (keep the generate step nx
run api-journeys-modern:generate-graphql unchanged); modify the line in SKILL.md
so the test command becomes the same invocation but including --runInBand.
- Around line 227-236: Update the migration docs to add regenerating the gateway
supergraph after the subgraph: run the command nx run
api-gateway:generate-graphql immediately after nx run
api-journeys-modern:generate-graphql (as part of Step 6), and instruct verifying
the composed schema at apis/api-gateway/schema.graphql contains the new field
annotated with `@join__field`(graph: API_JOURNEYS_MODERN, override:
"api-journeys"); reference the exact command name (nx run
api-gateway:generate-graphql) and the schema path so reviewers can locate and
validate the change.

In
`@apis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.spec.ts`:
- Around line 179-186: The current test in iconBlockUpdate.mutation.spec.ts only
asserts tx.block.update was called with data containing name and doesn't prevent
omitted fields from being set to null; update the assertion to also ensure the
update data does not include/overwrite omitted fields (e.g., color or size) by
asserting tx.block.update was called with a data object that contains the name
and explicitly does NOT contain keys like color or size (use negative/absence
assertions against tx.block.update's data argument) so partial updates leave
unspecified fields untouched.

In
`@apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.spec.ts`:
- Around line 189-193: The test currently asserts the soft-delete timestamp with
expect.any(String) which is brittle; update the assertion in the tx.block.update
expectation (the objectContaining with where: { id: 'oldCoverId' }) to be
representation-agnostic by replacing expect.any(String) with a
non-format-specific matcher such as expect.anything() or expect.not.toBeNull so
the test only verifies that deletedAt was set without enforcing a string format.

In
`@apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.ts`:
- Around line 53-80: The ImageBlock creation path writes a block that may modify
the block's `customizable` flag but only calls setJourneyUpdatedAt(tx, block);
after the DB write and after setJourneyUpdatedAt(tx, block) you must also invoke
the journey customizable recalculation routine (the function used elsewhere to
recompute journey-level `customizable` aggregates) passing the transaction and
the journey/block context (e.g., tx and block or input.journeyId) so the journey
aggregate is updated; locate this change near the ImageBlock create block and
call the existing recalculation helper immediately after setJourneyUpdatedAt.

In
`@apis/api-journeys-modern/src/schema/block/image/imageBlockUpdate.mutation.spec.ts`:
- Around line 16-18: The global mock of transformInput hides real
metadata-preserving behavior so the "alt-only" partial-update test doesn't catch
regressions clearing width/height/blurhash; update the tests so the alt-only
case uses the real transformInput (e.g., use jest.requireActual or jest.unmock
for transformInput just for that test) or add explicit assertions in the
alt-only test that width, height and blurhash are preserved after update; target
the mocked transformInput helper and the "alt-only" partial-update test so it
exercises/validates metadata preservation.

In `@apis/api-journeys-modern/src/schema/block/image/transformInput.ts`:
- Around line 30-43: The code in transformInput.ts currently calls
fetch(input.src) (and processes the response) which enables SSRF and resource
abuse; modify the implementation to stop trusting arbitrary URLs by either
requiring a pre-signed/uploaded file or routing image fetches through a trusted
proxy/allowlist service, and add strict safeguards: validate input.src against a
configured host allowlist, enforce network timeouts, check Content-Type and
Content-Length before reading, and enforce a maximum image size and decode
limits before passing buffer to sharp (update the logic around fetch(input.src),
Buffer.from(await response.arrayBuffer()), and subsequent sharp(...) calls).
Ensure these checks are centralized so callers supply only validated/resolved
image buffers or a safe URL.
- Around line 22-29: The current code always overwrites image metadata with
width:0/height:0/blurhash:'' before checking input.src, treating an absent
property like an explicit null; update transformInput (in transformInput.ts) so
you only clear metadata when input.src is explicitly null (input.src === null),
and if src is omitted (property not present / undefined) leave existing
width/height/blurhash untouched; move or conditionalize the assignments to
transformedInput (or build transformedInput differently) so the zeroing happens
only on explicit null while returning the original/input-spread otherwise.

In
`@apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.spec.ts`:
- Around line 168-175: The test currently only asserts that tx.block.update's
data includes label, which allows other fields to be sent as null; update the
assertion on tx.block.update (the call that includes where: { id }) so it
verifies the data payload is strictly a partial update with only the intended
keys: either assert data equals the exact object { label: 'Only label' } or, if
other keys exist on the mocked block, assert that those specific keys (e.g.,
description, options, etc. from the mocked block) are not present or not set to
null via negative assertions (e.g., expect.not.toHaveProperty or
expect.not.objectContaining) to guarantee no extra fields are sent as null when
calling tx.block.update for id.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e55f2344-344c-472d-a275-7d2e690fa281

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4a0dd and 0f11d93.

📒 Files selected for processing (17)
  • .cursor/skills/create-api-journeys-override/SKILL.md
  • apis/api-gateway/schema.graphql
  • apis/api-journeys-modern/schema.graphql
  • apis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/icon/index.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/image/index.ts
  • apis/api-journeys-modern/src/schema/block/image/transformInput.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/index.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockCreate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockCreate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.ts

Comment thread .cursor/skills/create-api-journeys-override/SKILL.md
Comment thread .cursor/skills/create-api-journeys-override/SKILL.md
Comment thread apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.ts Outdated
Comment thread apis/api-journeys-modern/src/schema/block/image/transformInput.ts
Comment thread apis/api-journeys-modern/src/schema/block/image/transformInput.ts
…Cursor, documenting Prisma and GraphQL update processes
@github-actions github-actions Bot temporarily deployed to Preview - short-links April 9, 2026 22:18 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - resources April 9, 2026 22:18 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 9, 2026 22:18 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch April 9, 2026 22:18 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 9, 2026 22:18 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys April 9, 2026 22:18 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin April 9, 2026 22:18 Inactive
@blacksmith-sh
Copy link
Copy Markdown
Contributor

blacksmith-sh Bot commented Apr 9, 2026

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
src/e2e/journeys.spec.ts/journeys View Logs

Fix in Cursor

@stage-branch-merger
Copy link
Copy Markdown
Contributor

I see you added the "on stage" label, I'll get this merged to the stage branch!

@mikeallisonJS mikeallisonJS added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit 96d9a69 Apr 9, 2026
39 of 40 checks passed
@mikeallisonJS mikeallisonJS deleted the 26-00-MA-chore-radiooptionblockupdate-modern branch April 9, 2026 23:09
tanflem pushed a commit that referenced this pull request Apr 13, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants