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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to export Submissions: Not allowed to write to file #2067

Open
chriscroome opened this issue Apr 15, 2024 · 13 comments
Open

Failed to export Submissions: Not allowed to write to file #2067

chriscroome opened this issue Apr 15, 2024 · 13 comments
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working feature: 馃摑 submitting responses
Milestone

Comments

@chriscroome
Copy link

chriscroome commented Apr 15, 2024

Please use the 馃憤 reaction to show that you are affected by the same issue. Please don't comment if you have no relevant information to add!

Describe the bug

A Nextcloud instance that did have a working Forms app now generates an error on form submission.

To Reproduce
Steps to reproduce the behaviour:

  1. Go to the form
  2. Complete it
  3. Click "Submit"
  4. The use has the error "There was an error submitting the form"

Expected behavior

A successfully submission.

Nextcloud (please complete the following information):

  • Nextcloud-Version: 28.0.4.1
  • Forms-Version: 4.2.0

Desktop (please complete the following information):

  • OS: Debian
  • Browser Firefox
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser Firefox/
  • Version 126.0

Browser log

[ERROR] forms: Error while submitting the form 
Object { app: "forms", level: 2, error: {鈥 }
NcSettingsSection-NSrCZ23G-6nKKlVz9.mjs:2:337806
    value https://cloud.example.org/apps/forms/js/NcSettingsSection-NSrCZ23G-6nKKlVz9.mjs:2
    value https://cloud.example.org/apps/forms/js/NcSettingsSection-NSrCZ23G-6nKKlVz9.mjs:2
    onConfirmedSubmit https://cloud.example.org/apps/forms/js/Submit-PS6lxYc-.mjs:2

Nextcloud log

The following is written to the Nextcloud log:

Failed to export Submissions: Not allowed to write to file

Server logs

There is nothing in the Apache or PHP-FPM logs.

TMPDIR

The tempdirectory is writable.

Additional context

The error that is produced appears to be here:

$this->logger->warning('Failed to export Submissions: Not allowed to write to file');

The change to the server (the forms were working prior to this change), was updating from Debian Bullseye to Debian Bookworm, the instance uses PHP-FPM 8.3.

I have tried to duplicate this on another server with the same configuration but haven't been able to.

@chriscroome chriscroome added 0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working labels Apr 15, 2024
@Chartman123
Copy link
Collaborator

Did you restart your php processes? Are you using php-fpm? We had lots of errors in the past after upgrades due to cached code...

@susnux
Copy link
Collaborator

susnux commented Apr 15, 2024

Browser log

Could you please provide the full object from the log? Including the error message?

@chriscroome
Copy link
Author

@Chartman123 PHP-FPM had been restarted.

@susnux here is a full log entry, all I have changed is the IP address and I also ran it through jq for formatting:

{
  "reqId": "oLRtH9XtF8rwtUiZidOT",
  "level": 2,
  "time": "2024-04-15T19:08:20+00:00",
  "remoteAddr": "X.X.X.X",
  "user": "--",
  "app": "forms",
  "method": "POST",
  "url": "/ocs/v2.php/apps/forms/api/v2.4/submission/insert",
  "message": "Failed to export Submissions: Not allowed to write to file",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0",
  "version": "28.0.4.1",
  "data": {
    "app": "forms"
  }
}

@susnux
Copy link
Collaborator

susnux commented Apr 15, 2024

Thank you, but @chriscroome what I meant is from you browser console there should be the network request that fails, could you please provide the response from the server?
For me it works and then looks like this:
Screenshot_20240415_211805

But for you there should be a more meaningful error message

@chriscroome
Copy link
Author

This is what I have after exporting it and changing the domain name:

[ERROR] forms: Error while submitting the form 
Object { app: "forms", level: 2, error: {鈥 }
NcSettingsSection-NSrCZ23G-6nKKlVz9.mjs:2:337806
    value https://cloud.example.com/apps/forms/js/NcSettingsSection-NSrCZ23G-6nKKlVz9.mjs:2
    value https://cloud.example.com/apps/forms/js/NcSettingsSection-NSrCZ23G-6nKKlVz9.mjs:2
    onConfirmedSubmit https://cloud.example.com/apps/forms/js/Submit-PS6lxYc-.mjs:2

Is that what you need?

@chriscroome
Copy link
Author

chriscroome commented Apr 15, 2024

I have also found 500 errors in the Apache and PHP-FPM logs, this in from the PHP-FPM access log:

- -  15/Apr/2024:19:31:23 +0000 "POST /ocs/v2.php" 500 /home/cloud/sites/nextcloud/ocs/v2.php 616.068 10240 45.45%

And this is from the Apache error log:

X.X.X.X - - [15/Apr/2024:19:31:23 +0000] "POST /ocs/v2.php/apps/forms/api/v2.4/submission/insert HTTP/2.0" 500 855 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"

@susnux
Copy link
Collaborator

susnux commented Apr 16, 2024

I could reproduce this on the instance, but there is not much helpful information for further debugging.
I guess some permission issues.

Where is the file located you want to export submissions to? A groupfolder? Local storage? Is the file or parent folder shared?

@chriscroome
Copy link
Author

I didn't set the form up so I don't know the answers to these questions I'm afraid but I have asked our client if they know the answers.

I think I have found the csv file on the file system and there doesn't apper to be any issue with the permissions or ownership -- the file is owned by the same user that PHP-FPM runs as and is 0644, the directory is 0775 and also owned by the same user that PHP-FPM runs as.

@mariomorvan
Copy link

The issue is still present on the instance mentioned by chriscroome.

I was able to make a new test form that leads to the same error message "There was an error submitting the form" whenever a submission is attempted by a user (except the owner of the form, for whom there is not such message).
The error comes up after a result spreadsheet is saved in a folder shared with the form owner (with edit rights).

If no spreadsheet is created, or if it is created in the form owner's personal space, no such issue was noticed.

@Chartman123
Copy link
Collaborator

@mariomorvan thanks for sharing this information with us. Are those "normal" shared folders or group folders or something else?

@mariomorvan
Copy link

@mariomorvan thanks for sharing this information with us. Are those "normal" shared folders or group folders or something else?

@Chartman123 thanks for looking into this. Normal share as far as I understand the different kind of shares (we do not have installed group folders)

@mariomorvan
Copy link

mariomorvan commented May 14, 2024

the logs show the following message associated with today's submission errors:

Exception OC\Files\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /home/cloud/sites/nextcloud/lib/private/Files/View.php on line 528 in file '/home/cloud/sites/nextcloud/lib/private/Files/View.php' line 1128
Exception thrown: Exception

@Chartman123
Copy link
Collaborator

Chartman123 commented May 15, 2024

@mariomorvan @susnux I could reproduce it this way:

  • User A shares folder with user B with full permissions
  • User B creates a form and links a spreadsheet in the shared folder
  • User B fills the form: everything works fine
  • If shared to all users of the instance: submission by logged in users works
  • Someone fills and submits the form via public share link (not logged in): submission fails

What's strange to me is that I don't get the original warning/error message but an error 500. Perhaps something else changed in the meantime. Heres the server logfile attached that I could see:

Logfile
{
	"reqId": "xavjYSv75SOGCm3N4niG",
	"level": 3,
	"time": "2024-05-15T08:43:50+00:00",
	"remoteAddr": "62.225.12.220",
	"user": "--",
	"app": "no app in context",
	"method": "POST",
	"url": "/ocs/v2.php/apps/forms/api/v2.4/submission/insert",
	"message": "OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/lib/private/Files/View.php on line 530 in file '/var/www/html/lib/private/Files/View.php' line 1132",
	"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0",
	"version": "29.0.0.19",
	"exception": {
		"Exception": "Exception",
		"Message": "OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/lib/private/Files/View.php on line 530 in file '/var/www/html/lib/private/Files/View.php' line 1132",
		"Code": 0,
		"Trace": [
			{
				"file": "/var/www/html/lib/private/AppFramework/App.php",
				"line": 184,
				"function": "dispatch",
				"class": "OC\\AppFramework\\Http\\Dispatcher",
				"type": "->",
				"args": [
					[
						"OCA\\Forms\\Controller\\ApiController"
					],
					"insertSubmission"
				]
			},
			{
				"file": "/var/www/html/lib/private/Route/Router.php",
				"line": 338,
				"function": "main",
				"class": "OC\\AppFramework\\App",
				"type": "::",
				"args": [
					"OCA\\Forms\\Controller\\ApiController",
					"insertSubmission",
					[
						"OC\\AppFramework\\DependencyInjection\\DIContainer"
					],
					[
						"v2.4",
						"ocs.forms.api.insertsubmission"
					]
				]
			},
			{
				"file": "/var/www/html/ocs/v1.php",
				"line": 66,
				"function": "match",
				"class": "OC\\Route\\Router",
				"type": "->",
				"args": [
					"/ocsapp/apps/forms/api/v2.4/submission/insert"
				]
			},
			{
				"file": "/var/www/html/ocs/v2.php",
				"line": 23,
				"args": [
					"/var/www/html/ocs/v1.php"
				],
				"function": "require_once"
			}
		],
		"File": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
		"Line": 170,
		"Previous": {
			"Exception": "TypeError",
			"Message": "OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/lib/private/Files/View.php on line 530",
			"Code": 0,
			"Trace": [
				{
					"file": "/var/www/html/lib/private/Files/View.php",
					"line": 530,
					"function": "basicOperation",
					"class": "OC\\Files\\View",
					"type": "->",
					"args": [
						"file_exists",
						null
					]
				},
				{
					"file": "/var/www/html/lib/private/Files/Filesystem.php",
					"line": 546,
					"function": "file_exists",
					"class": "OC\\Files\\View",
					"type": "->",
					"args": [
						null
					]
				},
				{
					"file": "/var/www/html/apps/files_versions/lib/Storage.php",
					"line": 190,
					"function": "file_exists",
					"class": "OC\\Files\\Filesystem",
					"type": "::",
					"args": [
						null
					]
				},
				{
					"file": "/var/www/html/apps/files_versions/lib/Listener/FileEventsListener.php",
					"line": 197,
					"function": "store",
					"class": "OCA\\Files_Versions\\Storage",
					"type": "::",
					"args": [
						null
					]
				},
				{
					"file": "/var/www/html/apps/files_versions/lib/Listener/FileEventsListener.php",
					"line": 103,
					"function": "write_hook",
					"class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
					"type": "->",
					"args": [
						[
							"OC\\Files\\Node\\File"
						]
					]
				},
				{
					"file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php",
					"line": 86,
					"function": "handle",
					"class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
					"type": "->",
					"args": [
						[
							"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent"
						]
					]
				},
				{
					"file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
					"line": 230,
					"function": "__invoke",
					"class": "OC\\EventDispatcher\\ServiceEventListener",
					"type": "->",
					"args": [
						[
							"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent"
						],
						"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent",
						[
							"Symfony\\Component\\EventDispatcher\\EventDispatcher"
						]
					]
				},
				{
					"file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
					"line": 59,
					"function": "callListeners",
					"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
					"type": "->",
					"args": [
						[
							[
								"Closure"
							],
							[
								"Closure"
							]
						],
						"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent",
						[
							"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent"
						]
					]
				},
				{
					"file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
					"line": 86,
					"function": "dispatch",
					"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
					"type": "->",
					"args": [
						[
							"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent"
						],
						"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent"
					]
				},
				{
					"file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
					"line": 98,
					"function": "dispatch",
					"class": "OC\\EventDispatcher\\EventDispatcher",
					"type": "->",
					"args": [
						"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent",
						[
							"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent"
						]
					]
				},
				{
					"file": "/var/www/html/lib/private/Files/Node/HookConnector.php",
					"line": 93,
					"function": "dispatchTyped",
					"class": "OC\\EventDispatcher\\EventDispatcher",
					"type": "->",
					"args": [
						[
							"OCP\\Files\\Events\\Node\\BeforeNodeWrittenEvent"
						]
					]
				},
				{
					"file": "/var/www/html/lib/private/legacy/OC_Hook.php",
					"line": 105,
					"function": "write",
					"class": "OC\\Files\\Node\\HookConnector",
					"type": "->",
					"args": [
						[
							true,
							"/Test_Forms/Test (Antworten).xlsx"
						]
					]
				},
				{
					"file": "/var/www/html/lib/private/Files/View.php",
					"line": 1276,
					"function": "emit",
					"class": "OC_Hook",
					"type": "::",
					"args": [
						"OC_Filesystem",
						"write",
						[
							true,
							"/Test_Forms/Test (Antworten).xlsx"
						]
					]
				},
				{
					"file": "/var/www/html/lib/private/Files/View.php",
					"line": 1148,
					"function": "runHooks",
					"class": "OC\\Files\\View",
					"type": "->",
					"args": [
						[
							"update",
							"write"
						],
						"/Test_Forms/Test (Antworten).xlsx"
					]
				},
				{
					"file": "/var/www/html/lib/private/Files/View.php",
					"line": 682,
					"function": "basicOperation",
					"class": "OC\\Files\\View",
					"type": "->",
					"args": [
						"file_put_contents",
						"/user.b/files/Test_Forms/Test (Antworten).xlsx",
						[
							"update",
							"write"
						],
						null
					]
				},
				{
					"file": "/var/www/html/lib/private/Files/Node/File.php",
					"line": 73,
					"function": "file_put_contents",
					"class": "OC\\Files\\View",
					"type": "->",
					"args": [
						"/user.b/files/Test_Forms/Test (Antworten).xlsx",
						null
					]
				},
				{
					"file": "/var/www/html/custom_apps/forms/lib/Service/SubmissionService.php",
					"line": 224,
					"function": "putContent",
					"class": "OC\\Files\\Node\\File",
					"type": "->",
					"args": [
						null
					]
				},
				{
					"file": "/var/www/html/custom_apps/forms/lib/Controller/ApiController.php",
					"line": 1145,
					"function": "writeFileToCloud",
					"class": "OCA\\Forms\\Service\\SubmissionService",
					"type": "->",
					"args": [
						[
							"OCA\\Forms\\Db\\Form",
							42
						],
						"/Test_Forms/Test (Antworten).xlsx",
						"xlsx",
						"user.b"
					]
				},
				{
					"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
					"line": 232,
					"function": "insertSubmission",
					"class": "OCA\\Forms\\Controller\\ApiController",
					"type": "->",
					"args": [
						42,
						[
							[
								"b"
							]
						],
						"ZadmE4kBLEXE4gSxTdmceJAg"
					]
				},
				{
					"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
					"line": 138,
					"function": "executeController",
					"class": "OC\\AppFramework\\Http\\Dispatcher",
					"type": "->",
					"args": [
						[
							"OCA\\Forms\\Controller\\ApiController"
						],
						"insertSubmission"
					]
				},
				{
					"file": "/var/www/html/lib/private/AppFramework/App.php",
					"line": 184,
					"function": "dispatch",
					"class": "OC\\AppFramework\\Http\\Dispatcher",
					"type": "->",
					"args": [
						[
							"OCA\\Forms\\Controller\\ApiController"
						],
						"insertSubmission"
					]
				},
				{
					"file": "/var/www/html/lib/private/Route/Router.php",
					"line": 338,
					"function": "main",
					"class": "OC\\AppFramework\\App",
					"type": "::",
					"args": [
						"OCA\\Forms\\Controller\\ApiController",
						"insertSubmission",
						[
							"OC\\AppFramework\\DependencyInjection\\DIContainer"
						],
						[
							"v2.4",
							"ocs.forms.api.insertsubmission"
						]
					]
				},
				{
					"file": "/var/www/html/ocs/v1.php",
					"line": 66,
					"function": "match",
					"class": "OC\\Route\\Router",
					"type": "->",
					"args": [
						"/ocsapp/apps/forms/api/v2.4/submission/insert"
					]
				},
				{
					"file": "/var/www/html/ocs/v2.php",
					"line": 23,
					"args": [
						"/var/www/html/ocs/v1.php"
					],
					"function": "require_once"
				}
			],
			"File": "/var/www/html/lib/private/Files/View.php",
			"Line": 1132
		},
		"message": "OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/lib/private/Files/View.php on line 530 in file '/var/www/html/lib/private/Files/View.php' line 1132",
		"exception": [],
		"CustomMessage": "OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/lib/private/Files/View.php on line 530 in file '/var/www/html/lib/private/Files/View.php' line 1132"
	},
	"id": "664475f19288c"
}

@Chartman123 Chartman123 added 1. to develop Accepted and waiting to be taken care of feature: 馃摑 submitting responses and removed 0. Needs triage Pending approval or rejection. This issue is pending approval. labels May 15, 2024
@Chartman123 Chartman123 added this to the 4.2.4 milestone May 15, 2024
@Chartman123 Chartman123 modified the milestones: 4.2.4, 4.2.5 May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working feature: 馃摑 submitting responses
Projects
None yet
Development

No branches or pull requests

4 participants