grist-core icon indicating copy to clipboard operation
grist-core copied to clipboard

Issue: URL for published form throws an error

Open nsmathew opened this issue 1 year ago • 15 comments

Function/Service

Forms

Issue

Updated to the latest version of grist today. It is running as a container in my self-hosted server. I tried the new forms functionality and created a form and published it. The link generated as part of the preview works fine, the data I key in gets saved in the appropriate table. However, when I try the link from the 'Copy Link' option in the form I get a page as shown in the screengrab.

Error message

There was an error: Unexpected token < in JSON at position 0.

Screenshot

NVIDIA_Share_keb5FGxPWV

nsmathew avatar Feb 06 '24 18:02 nsmathew

Thanks for reporting @nsmathew.

Could you share the link that was copied to your clipboard, excluding/censoring the shareKey part from the example below?

https://docs.getgrist.com/forms/${shareKey}/123

georgegevoian avatar Feb 06 '24 18:02 georgegevoian

Sure, it is https://mydomain.com/forms/<xxx>/258

nsmathew avatar Feb 06 '24 18:02 nsmathew

Thanks. Shape of the URL looks right to me.

Any chance you see an error trace in the server logs?

georgegevoian avatar Feb 06 '24 19:02 georgegevoian

This gets printed once I try to open the link image

nsmathew avatar Feb 06 '24 19:02 nsmathew

Thanks for the screenshot. A few lines just before the first line in your screenshot, there should be a line starting with GET /api/s/.... What's the status code you see for that request? Can you try dropping that path in front of your domain in the browser (e.g. https://mydomain.com/api/s/<xxx>/forms/258) and see if you get to the form page? Think I've narrowed down the problem but not positive yet.

georgegevoian avatar Feb 06 '24 20:02 georgegevoian

Had a look but I don't see any such lines in the docker logs.

nsmathew avatar Feb 06 '24 22:02 nsmathew

We have the same issue. Form Preview works and populates the table but the published link (https://mydomain.com/forms//1) returns a 400 error. It's self-hosted, behind an apache reverse proxy, we encounter no other issues. I'll post further debugging logs if it helps anyone.

A minor difference: the error message is "Fetch failed".

gdedrouas avatar Feb 23 '24 09:02 gdedrouas

@gdedrouas I also have encountered this issue in a local environment (in our production though we have a different issue). In our case, it's because the hostname of public URL for the home server cannot be resolved behind the reverse proxy.

That's something I meant to fix through this issue at first: https://github.com/gristlabs/grist-core/pull/864/files

It would mean that you would have to set a new env variable (at least in my case, it would solve my issue): APP_HOME_INTERNAL_URL.

But I was told that the guilty piece of code requiring that would probably be changed soon so this new env variable would not be necessary. So probably the PR I can close this PR @paulfitz?

fflorent avatar Feb 23 '24 10:02 fflorent

I can confirm that the request to "/api/s..." is never made. getHomeUrl fails in our environment.

gdedrouas avatar Feb 23 '24 10:02 gdedrouas

Getting same issue here in local environment, however, unlike @gdedrouas, I can view the preview form and submit, but it does not populate the table.

StreamlinedStartup avatar Feb 25 '24 05:02 StreamlinedStartup

The next sync to main (slated for early next week) will include a fix. Will report here once it's available.

georgegevoian avatar Feb 25 '24 05:02 georgegevoian

The sync of grist-saas code @georgegevoian mentioned happened this morning. The relevant change I think is this one: https://github.com/gristlabs/grist-core/commit/c6fd79ac1f08ab4146e3bca400325052b4ad257e

Maybe @georgegevoian can give more context. Sorry for how opaque this change was, we are slowly moving more development over to grist-core but it is still a work in progress.

paulfitz avatar Feb 26 '24 14:02 paulfitz

The latest image should now have the changes.

It's part of a broader refactor of forms, to more closely align with the other client-side Grist code. All forms API requests are now routed through DocApiForwarder, which should do a better job at building URLs that the home server can actually reach. I'm not sure if it'll address all of the issues (e.g. the submission issue @StreamlinedStartup reported, which may be unrelated), but please give it a try and let us know how it fares.

georgegevoian avatar Feb 26 '24 18:02 georgegevoian

It fixes the Fetch failed error I got when running local kubernetes pods! :)

Though the problem is different from the access denied error we have on our production (but we will give it a try at least to check), and for which we need to diagnose.

fflorent avatar Feb 27 '24 07:02 fflorent

It also fixes the Fetch failed error we got. Much appreciated.

gdedrouas avatar Mar 02 '24 17:03 gdedrouas