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

"files_insert_input" vs "storage_files_insert_input" #227

Open
rene-s opened this issue Oct 8, 2024 · 1 comment
Open

"files_insert_input" vs "storage_files_insert_input" #227

rene-s opened this issue Oct 8, 2024 · 1 comment

Comments

@rene-s
Copy link

rene-s commented Oct 8, 2024

Hi, thanks for providing nhost/hasura-storage and support! I'm kind of lost with this error though. I have upgraded from nhost/hasura-storage:0.3.6 (everything was working fine) to v0.6.1 and now I'm getting 403's when uploading files.

I have allowed roles "user" and "editor" to select the new field "metadata" and there is an ENV var "S3_ENDPOINT" as mentioned in the release notes. It was there all along.

This is the request I'm doing -- there is nothing particularly interesting about it, it has worked with v0.3.6:

curl 'https://example.com/v1/files' -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0' -H 'Accept: */*' -H 'Accept-Language: de,de-DE;q=0.8,en-US;q=0.5,en;q=0.3' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Referer: https://another.example.com/' -H 'Authorization: Bearer TOKEN' -H 'x-hasura-role: admin' -H 'Content-Type: multipart/form-data; boundary=---------------------------286635652437818198363019706553' -H 'Origin: https://another.example.com' -H 'DNT: 1' -H 'Sec-GPC: 1' -H 'Connection: keep-alive' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: cross-site' -H 'Priority: u=4' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-binary $'-----------------------------286635652437818198363019706553\r\nContent-Disposition: form-data; name="file[]"; filename="filename.jpg"\r\nContent-Type: image/jpeg\r\n\r\n-----------------------------286635652437818198363019706553--\r\n'

The TOKEN is valid, that's the same I'm using for Hasura.

With nhost/hasura-storage:0.6.1 response is a HTTP status 403:

{"error":{"message":"you are not authorized"}}

Container log shows this:

time="2024-10-07T19:15:45Z" level=error msg="call completed with some errors" 
client_ip=10.0.0.2 errors="[problem processing request: problem initializing file 
metadata: {\"networkErrors\":null,\"graphqlErrors\":[{\"message\":\"variable 'object'
 is declared as 'files_insert_input!', but used where 'storage_files_insert_input!' 
is expected\",\"extensions\":{\"code\":\"validation-failed\",\"path\":
\"$.selectionSet.insertFile.args.object\"}}]}]" latency_time=16.546408ms method=POST 
status_code=403 url=/v1/files

The file is not persisted in table "files" and the request does not even get passed through to S3/Minio.

I have manually tried to issue the mutation in Hasura as follows:

mutation InsertFile($object: files_insert_input!) {
  insertFile(object: $object) {
    id
  }
}

Query variables:

{
  "object": {
    "name": "example_file.txt",
    "bucketId": "default",
    "mimeType": "text/plain",
    "size": 2048
  }
}

I'm getting the same error ("variable 'object' is declared as 'files_insert_input!', but used where 'storage_files_insert_input!' is expected").

When I change files_insert_input to storage_files_insert_input it is working however, the record gets persisted.

Now, my question is why InitializeFile is using files_insert_input instead of storage_files_insert_input and what can I do to make it work? Thanks in advance!

@dbarrosop
Copy link
Member

Hello,
thanks for your message. It is using files_insert_input because that's the type name the service expects and that always expected. My guess is you modified the metadata in hasura and changed something that hasura-storage doesn't understand. Most likely by configuring the prefix "storage" to the schema. Otherwise, please, provide a minimal docker-compose file that reproduces the issue so we can take a look.

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