Skip to content
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

@relationDocument referring to an optional StreamID yields internal server error if unset #186

Closed
m0ar opened this issue Oct 17, 2023 · 5 comments

Comments

@m0ar
Copy link

m0ar commented Oct 17, 2023

Description

(discussed on Discord with @dbcfd, adding here for completeness)

In our code base we have the need for optional relations, but there seems to be a bug where the API errors out if a @relationDocument field refers to an unset property even if both the StreamID and the Thing is optional:

type Thing @loadModel(id: "xyz") {
  id: ID!
}

type Host
  @createModel(accountRelation: LIST, description: "Holding things")
{
  thingID: StreamID @documentReference(model: "Thing")    <--------- note optional
  thing: Thing @relationDocument(property: "thingID")     <--------- note optional
}

The error returned from the ceramic API:

Error: HTTP request to 'http://localhost:7007/api/v0/streams' failed with status 'Internal Server Error': 
{"error":"Error while parsing relation from field thingID: Invalid StreamID: Error: Unable to decode multibase string \"undefined\", base36 decoder only supports inputs prefixed with k"}

Technical Information

Since a StreamID field can be optional, a @relationDocument field referencing that property must also be optional.

@m0ar
Copy link
Author

m0ar commented Oct 25, 2023

This PR should fix the underlying problem: ceramicnetwork/js-ceramic#2999

I'm not able to figure out the correct overrides in my package.json to avoid this error, though (NOT NULL constraint).
Might need to wait for a release to confirm :)

Error: HTTP request to 'http://localhost:7007/api/v0/streams' failed with status 'Internal Server Error': {"error":"insert into `kjzl6hvfrbw6cap4qlstwhaflqx9jw517zw5h02m4khxog6jz3t6k05apg1hr2s` (`controller_did`, `created_at`, `custom_claimID`, `first_anchored_at`, `last_anchored_at`, `stream_content`, `stream_id`, `tip`, `updated_at`) values ('did:key:z6MknoDgHEeMqKES8P5MGMUcKA16Vbti9pCf6j8tu2GztiY1', 1698229060745, NULL, NULL, NULL, '{\"comment\":\"This is a cool object!\",\"targetID\":\"kjzl6kcym7w8yap35atjuv48weys0iix2foenkillgftr4m0f5t65xg84s5pbdf\",\"targetVersion\":\"k3y52mos6605bnw2edoy57ha7aifb7nqj5bhk7lw9kkwjkwsiztbfu5vdu08k0veo\"}', 'kjzl6kcym7w8y89s19uiwu1gu4ba2dzr2kavxdx6sp75ba3jkprxl9jfayz7cf4', 'bagcqceraq73obwfexolshdx2ozggojb4vkbfrvpqqn56vc3omscuqyrtmwqa', 1698229060745) on conflict (`stream_id`) do update set `stream_id` = 'kjzl6kcym7w8y89s19uiwu1gu4ba2dzr2kavxdx6sp75ba3jkprxl9jfayz7cf4',`controller_did` = 'did:key:z6MknoDgHEeMqKES8P5MGMUcKA16Vbti9pCf6j8tu2GztiY1',`stream_content` = '{\"comment\":\"This is a cool object!\",\"targetID\":\"kjzl6kcym7w8yap35atjuv48weys0iix2foenkillgftr4m0f5t65xg84s5pbdf\",\"targetVersion\":\"k3y52mos6605bnw2edoy57ha7aifb7nqj5bhk7lw9kkwjkwsiztbfu5vdu08k0veo\"}',`tip` = 'bagcqceraq73obwfexolshdx2ozggojb4vkbfrvpqqn56vc3omscuqyrtmwqa',`last_anchored_at` = NULL,`first_anchored_at` = NULL,`updated_at` = 1698229060745 - SQLITE_CONSTRAINT: NOT NULL constraint failed: kjzl6hvfrbw6cap4qlstwhaflqx9jw517zw5h02m4khxog6jz3t6k05apg1hr2s.custom_claimID"}

@m0ar
Copy link
Author

m0ar commented Jan 12, 2024

@dbcfd @stbrody I'm still not able to get around this on the latest version. Has ceramicnetwork/js-ceramic#2999 been included in a composedb release yet?

@stbrody
Copy link
Contributor

stbrody commented Jan 12, 2024

Sorry @m0ar, unfortunately the release of this has been held up by an unrelated bug that has been preventing us from making a new release of js-ceramic (you may have noticed it's been longer than usual since we've done a release). It's a major priority of the team right now to fix that bug so we can do a Ceramic release, which will include getting out this fix for optional relations.

@m0ar
Copy link
Author

m0ar commented Jan 12, 2024

Sorry @m0ar, unfortunately the release of this has been held up by an unrelated bug that has been preventing us from making a new release of js-ceramic (you may have noticed it's been longer than usual since we've done a release). It's a major priority of the team right now to fix that bug so we can do a Ceramic release, which will include getting out this fix for optional relations.

Makes total sense @stbrody , appreciate the context 🙏:cupcake:

@m0ar
Copy link
Author

m0ar commented Mar 8, 2024

This has been solved with v0.7! 🎊

@m0ar m0ar closed this as completed Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants