question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unclear Introspection error message: Error parsing attribute "@id": Fields that are marked as id must be required.

See original GitHub issue

Introspecting SQLite:

CREATE TABLE "playlist_track" (
	"PlaylistId"	INTEGER NOT NULL,
	"TrackId"	INTEGER NOT NULL,
	"id"	INTEGER PRIMARY KEY AUTOINCREMENT,
	FOREIGN KEY("PlaylistId") REFERENCES "playlists"("PlaylistId") ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY("TrackId") REFERENCES "tracks"("TrackId") ON DELETE NO ACTION ON UPDATE NO ACTION
)

Creates error message:

 ERROR  Oops, an unexpected error occured!
Schema parsing

error: Error parsing attribute "@id": Fields that are marked as id must be required.
  -->  schema.prisma:126
   |
125 |   TrackId    tracks
126 |   id         Int?      @id
   |

Error message does not include name of table/model for context.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
sorenbscommented, Feb 4, 2020

For clarification:

The consequence of inferring Integer PKs as Autoincrement NOT NULL (or as it would look like in the schema.prisma file: Int @id @default(autoincrement())) is that the id would be optional when writing, and non-null when reading.

DECISION: this is excellent!

See also https://github.com/prisma/specs/issues/176#issuecomment-561289686 for context on autoincrement syntax.

0reactions
do4grcommented, Mar 18, 2021

This can only occur on SQLite since only there are optional id fields valid DDL. Models with an optional Id will now be marked as @@ignore during introspection and won’t cause a validation error. If a model is handwritten with an optional id and without @@ignore, you’ll still get the same validation error which is then clear enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unclear Introspection error message: Error parsing attribute ...
Unclear Introspection error message : Error parsing attribute "@id": Fields that are marked as id must be required. #1368.
Read more >
prisma introspect generate invalid model - Stack Overflow
@relation error msg in : Error parsing attribute "@relation": The type of the field userId in the model posts is not matching the...
Read more >
GraphQL specification
In this query, the id , firstName , and lastName fields form a selection set. ... performed without losing information, then it must...
Read more >
HTML Standard
This is why, for instance, it is non-conforming to have two id attributes with ... Errors that involve areas that affect authors migrating...
Read more >
Error Codes and Descriptions - Travelport
0349, VAN transaction id: $? has been issued and cannot be cancelled or modified from ... 1006, Required attribute Queue Number in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found