-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Temporary patch for post Editor crash by empty attributes to block.json
#61933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Claude finished @kmanijak's task —— View job BC Review CompleteSummary: Overall Risk LowThis PR adds an empty The change is backwards compatible and low risk. Adding an empty attributes object does not alter block behavior, data storage, or API contracts. It's purely a schema addition that satisfies Gutenberg's internal validation requirements. BC AnalysisWhat ChangedFile: + "attributes": {},Before: Block had no BC Impact Assessment✅ No Breaking Changes Detected Why this is BC-safe:
Potential Risks (None Identified):
Additional Blocks at RiskDuring analysis, I identified two other blocks with the same pattern (color support + no attributes) that may also crash the editor with Gutenberg nightly:
Recommendation: Consider applying the same fix to these blocks in a follow-up PR once this workaround is validated, or wait for the upstream Gutenberg fix. Testing FocusPrimary Regression Areas:
Test Steps:
Changelog ReviewFile: ✅ Changelog is appropriate
Confidence: 95%Justification: This is a schema-only addition with no behavioral impact. The change pattern (empty attributes object) is well-understood in WordPress block development and widely used across core blocks. Risk is limited to potential edge cases in block serialization/deserialization, which are covered by existing WooCommerce block tests and GB nightly CI validation. The 5% uncertainty accounts for:
Ecosystem ImpactPayment Gateways: ❌ No impact (non-checkout block) Final Recommendation✅ Approve for merge This is a safe, minimal workaround for a legitimate Gutenberg regression. The change follows best practices and includes appropriate changelog entry. No deprecation needed as this adds functionality rather than removing it. Post-merge action: Monitor GB issue #73135 for upstream fix, then consider reverting this workaround or keeping it for older GB version compatibility. |
attributes to block.jsonattributes to block.json
Testing GuidelinesHi @adimoldovan @dinhtungdu , Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
📝 WalkthroughWalkthroughThis PR adds an empty attributes object to a Gutenberg block.json file as a temporary workaround to prevent editor crashes related to a Gutenberg regression. The change is classified as a patch-level tweak. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
plugins/woocommerce/changelog/fix-e2e-with-gb-regresssion(1 hunks)plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json(1 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: Aljullu
Repo: woocommerce/woocommerce PR: 61201
File: plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/product-image-gallery/edit.tsx:34-34
Timestamp: 2025-09-30T15:51:29.389Z
Learning: In WordPress blocks, `className` is managed through block supports (supports.className and supports.customClassName) rather than being a custom block attribute. The BlockEditProps generic type parameter should reflect only the custom attributes defined in block.json's attributes field, not the supports features.
📚 Learning: 2025-07-15T15:39:21.856Z
Learnt from: jorgeatorres
Repo: woocommerce/woocommerce PR: 59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.
Applied to files:
plugins/woocommerce/changelog/fix-e2e-with-gb-regresssion
📚 Learning: 2025-08-14T08:20:36.357Z
Learnt from: Aljullu
Repo: woocommerce/woocommerce PR: 60191
File: plugins/woocommerce/client/blocks/tests/e2e/tests/single-product-template/single-product-template-compatibility-layer.spec.ts:4-4
Timestamp: 2025-08-14T08:20:36.357Z
Learning: In WooCommerce e2e tests, some test files intentionally use hard-coded "woocommerce/woocommerce//" template IDs instead of BLOCK_THEME_SLUG to test backwards compatibility with the legacy plugin-scoped template ID format. These should not be updated to use the dynamic slug constant as they serve a specific testing purpose.
Applied to files:
plugins/woocommerce/changelog/fix-e2e-with-gb-regresssion
📚 Learning: 2025-08-07T10:34:27.723Z
Learnt from: jorgeatorres
Repo: woocommerce/woocommerce PR: 60250
File: .github/workflows/release-compile-changelog.yml:165-166
Timestamp: 2025-08-07T10:34:27.723Z
Learning: In WooCommerce release workflows, the VERSION variable used in changelog generation comes from the `validate-selected-branch-version` step, which extracts the version from `plugins/woocommerce/woocommerce.php` using `grep -oP '(?<=Version: )(.+)'` and validates it matches the input version. This ensures the version is always in the correct format by the time it reaches the changelog generation step, making additional error handling for version format validation unnecessary.
Applied to files:
plugins/woocommerce/changelog/fix-e2e-with-gb-regresssion
📚 Learning: 2025-09-12T09:29:11.840Z
Learnt from: Aljullu
Repo: woocommerce/woocommerce PR: 60767
File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/frontend.ts:246-253
Timestamp: 2025-09-12T09:29:11.840Z
Learning: In WooCommerce Add to Cart + Options blocks, when `childProductId` is defined (indicating a grouped product child), `selectedAttributes` is always an empty array. This is because grouped products don't have variations, so no additional guard is needed when passing `selectedAttributes` to `getProductData` for child product lookups.
Applied to files:
plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
📚 Learning: 2025-09-12T09:29:11.840Z
Learnt from: Aljullu
Repo: woocommerce/woocommerce PR: 60767
File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/frontend.ts:246-253
Timestamp: 2025-09-12T09:29:11.840Z
Learning: In WooCommerce Add to Cart + Options blocks, when `childProductId` is defined (indicating a grouped product child), `selectedAttributes` is always empty/undefined. This is because `selectedAttributes` is only initialized for variable products on the server side, and grouped products cannot be variable products simultaneously. Therefore, `getProductData` calls with `selectedAttributes` for child products work correctly without additional guards.
Applied to files:
plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
📚 Learning: 2025-08-22T11:04:16.818Z
Learnt from: yuliyan
Repo: woocommerce/woocommerce PR: 60554
File: plugins/woocommerce/templates/emails/block/customer-pos-completed-order.php:32-34
Timestamp: 2025-08-22T11:04:16.818Z
Learning: WordPress block.json schema does not have an "aliases" property. The "keywords" property is used for search/discovery terms, not block name aliases. Block name changes require block transforms to map old block names to new ones.
Applied to files:
plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
📚 Learning: 2025-08-22T10:24:05.067Z
Learnt from: yuliyan
Repo: woocommerce/woocommerce PR: 60554
File: plugins/woocommerce/client/blocks/bin/webpack-entries.js:62-62
Timestamp: 2025-08-22T10:24:05.067Z
Learning: WooCommerce blocks use their own block asset API system rather than standard WordPress block.json asset referencing. WC blocks extend AbstractBlock and use methods like get_block_type_editor_script() that leverage $this->asset_api->get_block_asset_build_path() to handle asset registration, instead of defining editorScript, viewScript, or style fields directly in block.json.
Applied to files:
plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
📚 Learning: 2025-07-24T05:37:00.907Z
Learnt from: dinhtungdu
Repo: woocommerce/woocommerce PR: 59900
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/attribute-filter/inspector.tsx:0-0
Timestamp: 2025-07-24T05:37:00.907Z
Learning: The DisplayStyleSwitcher component in plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/components/display-style-switcher/index.tsx has been updated so that its onChange prop accepts only a string type (not string | number | undefined), eliminating the need for type assertions when using this component.
Applied to files:
plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
📚 Learning: 2025-09-30T15:51:29.389Z
Learnt from: Aljullu
Repo: woocommerce/woocommerce PR: 61201
File: plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/product-image-gallery/edit.tsx:34-34
Timestamp: 2025-09-30T15:51:29.389Z
Learning: In WordPress blocks, `className` is managed through block supports (supports.className and supports.customClassName) rather than being a custom block attribute. The BlockEditProps generic type parameter should reflect only the custom attributes defined in block.json's attributes field, not the supports features.
Applied to files:
plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
📚 Learning: 2025-07-28T07:20:49.002Z
Learnt from: Aljullu
Repo: woocommerce/woocommerce PR: 60045
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductGalleryThumbnails.php:68-68
Timestamp: 2025-07-28T07:20:49.002Z
Learning: WordPress block.json files support JSON schema pattern validation for string attributes using the "pattern" property with regular expression syntax, which provides client-side validation in the block editor.
Applied to files:
plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: review-with-tracking
- GitHub Check: build
...ts/js/blocks/add-to-cart-with-options/grouped-product-selector/product-item-label/block.json
Show resolved
Hide resolved
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
|
I think this is more of a core issue, and doing this will just hide it under the rug. If we do it, let's make sure to revert it afterwards. |
adimoldovan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for patching this @kmanijak
Yeah, we'll do! While I agree about hiding under the rug, we often noticed the opposite effect when keeping the error failing, would cover other issues happening at the same time because we get used to failing tests. So I'll keep it and will remove later on! |
Submission Review Guidelines:
Changes proposed in this Pull Request:
There's a regression in GB WordPress/gutenberg#73135 that Editor crashes (blank page) if you register a block with block.json that has:
attributesdefinition - it's not required thoughsupports.colorfieldAs a temporary measure, this PR adds empty
attributesto the block that matches the criteria causing post Editor to crashCloses # .
(For Bug Fixes) Bug introduced in PR # .
Screenshots or screen recordings:
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Testing that has already taken place:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment