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

Attempting to create a relationship via API POST to /api/relations endpoint returns an error #3059

Closed
akersj opened this issue Jan 21, 2022 · 0 comments

Comments

@akersj
Copy link

akersj commented Jan 21, 2022

If you attempt to create a relationship via API POST to /api/relations with a valid payload the caller is returned 500 Internal Server Error with payload:

{
  "@context": "/api/contexts/Error",
  "@type": "hydra:Error",
  "hydra:title": "An error occurred",
  "hydra:description": "Variable \"‘api\" is not valid around position 12 for expression `is_granted(‘api:post’)`.",
  "trace": [
    {
      "namespace": "",
      "short_class": "",
      "class": "",
      "type": "",
      "function": "",
      "file": "/Users/jamie/Desktop/Hotarucon/vendor/symfony/expression-language/Parser.php",
      "line": 230,
      "args": []
    },

(rest of stack trace removed as it adds little value)

Details

Question Answer
Relevant Bolt Version 5.1.0
Install type Composer install
BC Break n/a
PHP version 7.4
Web server Apache
For UX/UI issues n/a

Reproduction

Send a valid POST request to /api/relations using Postman or Bolt's built-in API tools. E.g.

{
  "fromContent": "/api/contents/123",
  "toContent": "/api/contents/116",
  "position": 0
}

Expected result

The caller is returned 200 OK with a payload describing the new relationship.

Actual result

The caller is returned 500 Internal Server Error with a payload including a stack trace.

Potential cause

(My apologies I am a software tester by trade not a developer!)
In /src/Entity/Relation.php on line 18 the wrong quotation marks are used around api:post.

Bug:
* "post"={"security"="is_granted(‘api:post’)"}

Correct:
* "post"={"security"="is_granted('api:post')"}

Joossensei added a commit that referenced this issue Jan 24, 2022
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