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

Provide a default behavior to return valid JSON on /api/rest/projects/{projectId}/commits/{commitId}/changes #4414

Open
4 tasks done
ctmbl opened this issue Jan 14, 2025 · 4 comments · May be fixed by #4457
Open
4 tasks done

Comments

@ctmbl
Copy link

ctmbl commented Jan 14, 2025

  • I have checked that this bug has not yet been reported by someone else
  • I have checked that this bug appears on Chrome
  • I have specified the version :
  • I have specified my environment :
  • WSL

Screenshots

#4393 (comment)

402597922-1a053ae9-92fc-4a5b-8e4d-d26bb9459122

402598125-fb7f45cc-31ce-4b61-bbbd-52a28fc48e16

402598377-45b44a83-48d2-45e9-bf01-295e36a108a6
https://jsonformatter.curiousconcept.com/#

Steps to reproduce

  1. Create some project on Sirius Web (tested with Flow, Studio, custom domain, Papaya example and blank)
  2. Perform a GET on the endpoint /api/rest/projects/{projectId}/commits/{commitId}/changes
# for example in python
import requests
resp = requests.get("http://localhost:8080/api/rest/projects/6ea46518-424f-4b88-bbc1-1afc2887d587/commits/6ea46518-424f-4b88-bbc1-1afc2887d587/changes")
print(resp.text)

see

[
  {
    "@id":"9f9cfa8d-3fd8-3fab-8e3d-38e3dd556b06",
    "@type":"DataVersion",
    "identity": {
        "@id":"84d67606-4956-46df-8db1-2ac203dd831e",
        "@type":"DataIdentity"
     },
    "payload"
  },
...

Expected behavior

Return valid RFC 8259 JSON

For example when no payload is defined return:

...
  "payload": null
...

Actual behavior

"payload" key with no value associated:

...
  "payload"
...

according to @AxelRICHARD :

This payload contains data specific to your metamodel.
You should implement your own version of IRestDataVersionPayloadSerializerService.java to serialize it as you want.
An example is available in SysON, a Sirius Web-based open source project.

@ctmbl
Copy link
Author

ctmbl commented Jan 16, 2025

tested on d4df511

I'll take advantage of this opened issue to share to other strange behaviours of the API

Infinite Loops

/api/rest/projects/{projectId}/commits/{commitId}/roots and /api/rest/projects/{projectId}/commits/{commitId}/elements suffers from infinite loop and return not valid JSON because of a nesting depth reached in the backend:

2025-01-16T11:52:22.259+01:00  WARN 4604 --- [io-8080-exec-10] .w.s.m.s.DefaultHandlerExceptionResolver : Ignoring exception, response committed already: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Document nesting depth (1001) exceeds the maximum allowed (1000, from `StreamWriteConstraints.getMaxNestingDepth()`)
2025-01-16T11:52:22.259+01:00  WARN 4604 --- [io-8080-exec-10] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Document nesting depth (1001) exceeds the maximum allowed (1000, from `StreamWriteConstraints.getMaxNestingDepth()`)]

examples to reproduce:

  • create a Blank Studio with a simple Entity containing itself:
    Image
    access http://localhost:8080/api/rest/projects/<your-project-id>/commits/<your-project-id>/roots
  • create a new project from the Flow template:
    access http://localhost:8080/api/rest/projects/<your-project-id>/commits/<your-project-id>/roots
[
    {
        "consumption": 0,
        "powerStatus": "NONE",
        "status": "ACTIVE",
        "usage": "UNUSED",
        "outgoingFlows": [],
        "name": "NewSystem",
        "elements": [
            {
                "consumption": 0,
                "powerStatus": "NONE",
                "status": "ACTIVE",
                "usage": "UNUSED",
                "outgoingFlows": [],
                "name": "CompositeProcessor1",
                "elements": [
                    {
                        "status": "ACTIVE",
                        "usage": "UNUSED",
                        "incomingFlows": [
                            {
                                "status": "ACTIVE",
                                "usage": "STANDARD",
                                "capacity": 6,
                                "load": 6,
                                "target": {
                                    "status": "ACTIVE",
                                    "usage": "UNUSED",
                                    "incomingFlows": [
                                        {
                                            "status": "ACTIVE",
                                            "usage": "STANDARD",
                                            "capacity": 6,
                                            "load": 6,
                                            "target": {
                                                "status": "ACTIVE",
                                                "usage": "UNUSED",
                                                "incomingFlows": [
                                                    {
                                                        "status": "ACTIVE",
                                                        "usage": "STANDARD",
                                                        "capacity": 6,
                                                        "load": 6,
                                                        "target": {
                                                            "status": "ACTIVE",
                                                            "usage": "UNUSED",
                                                            "incomingFlows": [
                                                                {
                                                                    "status": "ACTIVE",
                                                                    "usage": "STANDARD",
                                                                    "capacity": 6,
                                                                    "load": 6,
                                                                    "target": {
... (goes on and on through target -> incomingFlows -> target)

Unhandled exception

/api/rest/projects/{projectId}/commits/{commitId}/roots and /api/rest/projects/{projectId}/commits/{commitId}/elements throw an unhandled exception in the backend for instances of custom domain (Studio?) created in Sirius Web. Thus not returning any JSON but a template HTML.
This seemed to be caused by a lack of serializer:

2025-01-16T12:03:07.218+01:00 ERROR 4604 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.eclipse.emf.ecore.impl.DynamicEObjectImpl]] with root cause

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.eclipse.emf.ecore.impl.DynamicEObjectImpl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0])
        at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77) ~[jackson-databind-2.18.2.jar!/:2.18.2]
...

steps to reproduce:

  • Create a new Studio (not a blank one)
    Image
  • Create a new blank project
    Image
  • Add an object from the previously created Studio
    Image
  • access http://localhost:8080/api/rest/projects/<your-project-id>/commits/<your-project-id>/roots
  • this should throw an exception in the backend as shown above

Please let me know if these behaviours are expected, or if you want me to create separate issues 🙂

@ctmbl
Copy link
Author

ctmbl commented Jan 21, 2025

Hi @AxelRICHARD and @sbegaudeau ,
Sorry for the intrusive ping but could you assign labels to this issue? I wouldn't want it to fall into oblivion 😅

@AxelRICHARD
Copy link
Contributor

tested on d4df511

I'll take advantage of this opened issue to share to other strange behaviours of the API

....

Please let me know if these behaviours are expected, or if you want me to create separate issues 🙂

Yes, please open separate issues for each different point mentioned above in your second response.
But it is not a priority to provide a serializer for the studio/flow/papaya metamodels, so I can't guarantee we will do anything about it.

About the first issue, related to the payload attribute, I will provide a fix soon.

Thank you,

Regards

@AxelRICHARD AxelRICHARD added this to the 2025.2.0 milestone Jan 22, 2025
@AxelRICHARD AxelRICHARD self-assigned this Jan 22, 2025
AxelRICHARD added a commit that referenced this issue Jan 22, 2025
@AxelRICHARD AxelRICHARD linked a pull request Jan 22, 2025 that will close this issue
39 tasks
@AxelRICHARD AxelRICHARD linked a pull request Jan 22, 2025 that will close this issue
39 tasks
@ctmbl
Copy link
Author

ctmbl commented Jan 23, 2025

About the first issue, related to the payload attribute, I will provide a fix soon.

Thanks a lot!

But it is not a priority to provide a serializer for the studio/flow/papaya metamodels, so I can't guarantee we will do anything about it.

No worries, I totally understand 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants