Blocks disappear on /jsonapi/block/block endpoint when visibility is used

Created on 26 January 2022, over 2 years ago
Updated 14 May 2024, about 1 month ago

Problem/Motivation

if a block (either system or custom)'s visibility settings is used, it disappear from jsonapi/block/block endpoint

Steps to reproduce

1. Fresh install latest stable, and enable jsonapi module in core
2. create a custom block, e.g. "Test Block", and place it in a region, e.g. header
3. Visit /jsonapi/block/block, see if the "Test Block" shows up (it should)
4. Edit the "Test Block", under Visitbility -> page setting, add a path /test
5. Visit /jsonapi/block/block, see if the "Test Block" shows up, it won't

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
JSON API 

Last updated about 6 hours ago

Created by

🇨🇳China skyredwang Shanghai

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India Vishal Choudhary Dharmshala

    Only simple custom blocks render in the working part of this API endpoint. The output includes various attributes such as
    },
    "drupal_internal__id": "olivero_testblock",
    "theme": "olivero",
    "region": "header",
    "weight": 0,
    "provider": null,
    "plugin": "block_content:e3ad9b86-ed1c-4711-b104-55cc4c5e2598",
    "settings": {
    "id": "block_content:e3ad9b86-ed1c-4711-b104-55cc4c5e2598",
    "label": "Test Block",
    "label_display": "visible",
    "provider": "block_content",
    "status": true,
    "info": "",
    "view_mode": "full"
    },
    "visibility": {
    "response_status": {
    "id": "response_status",
    "negate": false,
    "status_codes": [
    200
    ]
    }
    }
    }
    }

    However, there's an issue in a second scenario: if the user sets the page path on the same block and saves the block layout, the block output doesn't appear in the API Endpoint. This poses a significant problem, especially when a block is placed in the block region with the page path and fails to show in base_url/jsonapi/block/block.

    There's a need to address this functionality. Are there any alternative solutions available for resolving this issue?

Production build 0.69.0 2024