Skip to content

hasOne relationship dropdown not populating correctly in a repeatable component #21517

@gmoigneu

Description

@gmoigneu

Bug report

Required System information

  • Node.js version: v20.17.0
  • NPM version: yarn/1.22.22
  • Strapi version: 5.0.1
  • Database: Postgres
  • Operating system: MacOS Sequoia
  • Is your project Javascript or Typescript: TS

Describe the bug

When adding or edting a repeatable component that has a hasOne relation, the dropdown for that relationship is empty at first. You have to Save the type for the dropdown to populate.

Sometimes it is required to save multiple times. Some other times, some entities are not in the list and you need to Save again so they appear.

The problem appears on all relations no matter the type in the project. Tested on a blank new project as well.

Strapi generates a SQL error:

[2024-09-28 08:47:10.026] error: select "t0".*, "t0"."id" from "public"."components_pages_icon_text_blocks" as "t0" where ("t0"."id" = $1) limit $2 - invalid input syntax for type integer: "kutz88nv52j0tus2p3ajodn2"
error: select "t0".*, "t0"."id" from "public"."components_pages_icon_text_blocks" as "t0" where ("t0"."id" = $1) limit $2 - invalid input syntax for type integer: "kutz88nv52j0tus2p3ajodn2"
    at Parser.parseErrorMessage (/Users/nls/projects/arkea-rebuild/backend/node_modules/pg-protocol/src/parser.ts:368:69)
    at Parser.handlePacket (/Users/nls/projects/arkea-rebuild/backend/node_modules/pg-protocol/src/parser.ts:187:21)
    at Parser.parse (/Users/nls/projects/arkea-rebuild/backend/node_modules/pg-protocol/src/parser.ts:102:30)
    at Socket.<anonymous> (/Users/nls/projects/arkea-rebuild/backend/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:domain:488:12)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)

It actually tries to find the component (IconTextBlock) instance by document ID instead of integer ID.

Steps to reproduce the behavior

  1. Edit a dynamic zone with a repeatable component with a hasOne relation
  2. Add an instance of the component
  3. Try to select the related entity, the dropdown is empty
  4. Save
  5. Now the dropdown is populated

Expected behavior

The relation dropdown should be populated with all published entities by default.

Screenshots

2024-09-28 08 32 41

2024-09-28 08 46 16

Code snippets

N/A

Additional context

N/A

Metadata

Metadata

Assignees

Labels

issue: bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundsource: core:content-managerSource is core/content-manager packagestatus: can not reproduceNot enough information to reproduceversion: 5Issue is present in Strapi 5

Type

No type

Projects

Status

Fixed/Shipped

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions