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

[Bug]: Error Message popup not showing in OdataV2 in FE scenario #415

Closed
jeremycoppey opened this issue Nov 17, 2023 · 6 comments · Fixed by #426
Closed

[Bug]: Error Message popup not showing in OdataV2 in FE scenario #415

jeremycoppey opened this issue Nov 17, 2023 · 6 comments · Fixed by #426
Assignees
Labels
bug Something isn't working external

Comments

@jeremycoppey
Copy link

jeremycoppey commented Nov 17, 2023

OData Version

OData V2

Draft

No

Scenario

Fiori elements, List Report

UI5 Spreadsheet Component

29

What happened?

In case of a odata 400 Bad Request response in our Batch (this is a 202) we don't get the messagehandler displayed.
While debugging we do not enter the following piece of code (ODataV2-dbg.js file function checkForErrors line 42):
Line 44 returns false as this.submitChangesResponse is empty
So we never get to check the firstResponse nor the showBackendErrorMessages to display the Messages dialog
image

Relevant log output

assert-dbg.js:33  Assertion failed: ManagedObject sap.ui.core.Fragment#__fragment4: encountered unknown setting 'size' for class sap.m.ProgressIndicator (value:'1.5rem')
a @ assert-dbg.js:33
(anonymous) @ XMLTemplateProcessor-dbg.js:1207
(anonymous) @ SyncPromise-dbg.js:309
c @ SyncPromise-dbg.js:60
S @ SyncPromise-dbg.js:225
S.then @ SyncPromise-dbg.js:308
k1 @ XMLTemplateProcessor-dbg.js:1051
(anonymous) @ XMLTemplateProcessor-dbg.js:997
Promise.then (async)
j1 @ XMLTemplateProcessor-dbg.js:996
i1 @ XMLTemplateProcessor-dbg.js:937
E1 @ XMLTemplateProcessor-dbg.js:1347
Promise.then (async)
p @ XMLTemplateProcessor-dbg.js:208
k1 @ XMLTemplateProcessor-dbg.js:1413
j1 @ XMLTemplateProcessor-dbg.js:1001
i1 @ XMLTemplateProcessor-dbg.js:937
E1 @ XMLTemplateProcessor-dbg.js:1347
Promise.then (async)
p @ XMLTemplateProcessor-dbg.js:208
E1 @ XMLTemplateProcessor-dbg.js:1289
Promise.then (async)
p @ XMLTemplateProcessor-dbg.js:208
k1 @ XMLTemplateProcessor-dbg.js:1413
j1 @ XMLTemplateProcessor-dbg.js:1001
(anonymous) @ XMLTemplateProcessor-dbg.js:767
(anonymous) @ SyncPromise-dbg.js:309
c @ SyncPromise-dbg.js:60
S @ SyncPromise-dbg.js:225
S.then @ SyncPromise-dbg.js:308
f1 @ XMLTemplateProcessor-dbg.js:764
g1 @ XMLTemplateProcessor-dbg.js:828
f1 @ XMLTemplateProcessor-dbg.js:758
G @ XMLTemplateProcessor-dbg.js:613
z.parseTemplatePromise @ XMLTemplateProcessor-dbg.js:340
init @ Fragment-dbg.js:812
F._initCompositeSupport @ Fragment-dbg.js:190
(anonymous) @ ManagedObject-dbg.js:529
constructor @ ManagedObject-dbg.js:553
constructor @ Fragment-dbg.js:122
d @ Fragment-dbg.js:395
(anonymous) @ Fragment-dbg.js:408
Promise.then (async)
(anonymous) @ Fragment-dbg.js:406
f @ Fragment-dbg.js:405
F.load @ Fragment-dbg.js:511
e @ OData-dbg.js:143
e @ OData-dbg.js:34
(anonymous) @ SpreadsheetUploadDialog-dbg.js:150
i @ SpreadsheetUploadDialog-dbg.js:149
e @ SpreadsheetUploadDialog-dbg.js:175
await in e (async)
b.fireEvent @ EventProvider-dbg.js:247
d.fireEvent @ Element-dbg.js:631
(anonymous) @ ManagedObjectMetadata-dbg.js:789
k.ontap @ Button-dbg.js:542
d._handleEvent @ Element-dbg.js:342
U._handleEvent @ UIArea-dbg.js:947
dispatch @ jquery-dbg.js:5430
g @ jquery-mobile-custom-dbg.js:1902
q @ jquery-mobile-custom-dbg.js:2022
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234
trigger @ jquery-dbg.js:8823
(anonymous) @ jquery-dbg.js:8901
each @ jquery-dbg.js:385
each @ jquery-dbg.js:207
trigger @ jquery-dbg.js:8900
R @ jquery-mobile-custom-dbg.js:1455
S @ jquery-mobile-custom-dbg.js:1465
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234
Log-dbg.js:452  2023-11-17 13:02:52.748899 Request failed with status code 400: POST ZTG_C_CONDITION_M - [{"code":"ZTG/009","message":"The LC Category TEST doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"},{"code":"ZTG/009","message":"The Management Mode T doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"},{"code":"ZTG/009","message":"The Funded Program TEST STRING doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"},{"code":"ZTG/009","message":"The Commitment Item TEST STRING doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"},{"code":"ZTG/009","message":"The Fund Center TEST STRING doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"},{"code":"ZTG/009","message":"The Business Object TEST STRING doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"},{"code":"ZTG/009","message":"The Company Code TEST associated to Tag Id TEST STRIN doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"},{"code":"ZTG/009","message":"The TagId TEST STRIN associated to Company Code TEST doesn't exist in system","persistent":true,"targets":["/ZTG_C_CONDITION_M('id-1700222565093-194')"],"type":"Error"}] sap.ui.model.odata.ODataMessageParser
f @ Log-dbg.js:452
L.error @ Log-dbg.js:232
e._logErrorMessages @ ODataMessageParser-dbg.js:735
e.parse @ ODataMessageParser-dbg.js:173
Q._parseResponse @ ODataModel-dbg.js:7220
Q._handleError @ ODataModel-dbg.js:4567
Q._processError @ ODataModel-dbg.js:4295
$ @ ODataModel-dbg.js:3480
a1 @ ODataModel-dbg.js:3538
Z @ ODataModel-dbg.js:3256
(anonymous) @ ODataModel-dbg.js:6974
(anonymous) @ datajs.js:17
p9 @ datajs.js:17
XMLHttpRequest.send (async)
request @ datajs.js:17
E2 @ datajs.js:17
o.request @ datajs.js:17
Q._request @ ODataModel-dbg.js:6980
d1 @ ODataModel-dbg.js:3340
(anonymous) @ ODataModel-dbg.js:3299
Promise.then (async)
b1 @ ODataModel-dbg.js:3294
Q._submitRequest @ ODataModel-dbg.js:3360
Q._submitBatchRequest @ ODataModel-dbg.js:3594
(anonymous) @ ODataModel-dbg.js:4013
e @ each-dbg.js:61
Q._processRequestQueue @ ODataModel-dbg.js:3963
(anonymous) @ ODataModel-dbg.js:4069
Promise.then (async)
(anonymous) @ ODataModel-dbg.js:4068
Promise.then (async)
Q._processRequestQueueAsync @ ODataModel-dbg.js:4067
(anonymous) @ ODataModel-dbg.js:6795
Promise.then (async)
r1 @ ODataModel-dbg.js:6792
Q.createEntry @ ODataModel-dbg.js:6806
(anonymous) @ ODataV2-dbg.js:25
s @ ODataV2-dbg.js:23
t @ ODataV2-dbg.js:36
t @ ODataV2-dbg.js:39
e @ OData-dbg.js:50
await in e (async)
(anonymous) @ SpreadsheetUploadDialog-dbg.js:150
i @ SpreadsheetUploadDialog-dbg.js:149
e @ SpreadsheetUploadDialog-dbg.js:175
await in e (async)
b.fireEvent @ EventProvider-dbg.js:247
d.fireEvent @ Element-dbg.js:631
(anonymous) @ ManagedObjectMetadata-dbg.js:789
k.ontap @ Button-dbg.js:542
d._handleEvent @ Element-dbg.js:342
U._handleEvent @ UIArea-dbg.js:947
dispatch @ jquery-dbg.js:5430
g @ jquery-mobile-custom-dbg.js:1902
q @ jquery-mobile-custom-dbg.js:2022
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234
trigger @ jquery-dbg.js:8823
(anonymous) @ jquery-dbg.js:8901
each @ jquery-dbg.js:385
each @ jquery-dbg.js:207
trigger @ jquery-dbg.js:8900
R @ jquery-mobile-custom-dbg.js:1455
S @ jquery-mobile-custom-dbg.js:1465
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234
Log-dbg.js:452  2023-11-17 13:02:52.754000 Error while calling the odata service - [object Object] SpreadsheetUpload: callOdata
f @ Log-dbg.js:452
L.error @ Log-dbg.js:232
e @ OData-dbg.js:79
await in e (async)
(anonymous) @ SpreadsheetUploadDialog-dbg.js:150
i @ SpreadsheetUploadDialog-dbg.js:149
e @ SpreadsheetUploadDialog-dbg.js:175
await in e (async)
b.fireEvent @ EventProvider-dbg.js:247
d.fireEvent @ Element-dbg.js:631
(anonymous) @ ManagedObjectMetadata-dbg.js:789
k.ontap @ Button-dbg.js:542
d._handleEvent @ Element-dbg.js:342
U._handleEvent @ UIArea-dbg.js:947
dispatch @ jquery-dbg.js:5430
g @ jquery-mobile-custom-dbg.js:1902
q @ jquery-mobile-custom-dbg.js:2022
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234
trigger @ jquery-dbg.js:8823
(anonymous) @ jquery-dbg.js:8901
each @ jquery-dbg.js:385
each @ jquery-dbg.js:207
trigger @ jquery-dbg.js:8900
R @ jquery-mobile-custom-dbg.js:1455
S @ jquery-mobile-custom-dbg.js:1465
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234
Log-dbg.js:452  2023-11-17 13:02:52.754600 Error while calling the odata service - [object Object] SpreadsheetUpload: onUploadSet
f @ Log-dbg.js:452
L.error @ Log-dbg.js:232
e @ SpreadsheetUploadDialog-dbg.js:178
await in e (async)
b.fireEvent @ EventProvider-dbg.js:247
d.fireEvent @ Element-dbg.js:631
(anonymous) @ ManagedObjectMetadata-dbg.js:789
k.ontap @ Button-dbg.js:542
d._handleEvent @ Element-dbg.js:342
U._handleEvent @ UIArea-dbg.js:947
dispatch @ jquery-dbg.js:5430
g @ jquery-mobile-custom-dbg.js:1902
q @ jquery-mobile-custom-dbg.js:2022
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234
trigger @ jquery-dbg.js:8823
(anonymous) @ jquery-dbg.js:8901
each @ jquery-dbg.js:385
each @ jquery-dbg.js:207
trigger @ jquery-dbg.js:8900
R @ jquery-mobile-custom-dbg.js:1455
S @ jquery-mobile-custom-dbg.js:1465
dispatch @ jquery-dbg.js:5430
t3.handle @ jquery-dbg.js:5234

Spreadsheet Component Init

this.spreadsheetUpload = await this.getView().getController().getOwnerComponent().createComponent({
	usage: "spreadsheetImporter",
	async: true,
	componentData: {
			context: this,
			tableId:"com.xxxx.tagmanager::sap.suite.ui.generic.template.ListReport.view.ListReport::ZTG_C_TAG_M--responsiveTable-CONDITION",
			mandatoryFields: ["TagId", "CompanyCode","ObjectTypeId"],
			showBackendErrorMessages: true
	}
});

Manifest

"resourceRoots": {
   "cc.spreadsheetimporter.v0_29_0": "./thirdparty/customControl/spreadsheetImporter/v0_29_0"
},
"componentUsages": {
   "spreadsheetImporter": {
        "name": "cc.spreadsheetimporter.v0_29_0"
   }
},
@jeremycoppey jeremycoppey added bug Something isn't working external labels Nov 17, 2023
@marianfoo
Copy link
Member

Sorry, i was not able to recreate it.
I triggered a 400 response in my backend and this.submitChangesResponse was not empty.
What kind of SAPUI5 Version do you have?

image

Can you check if there are information in row 83?
I do not have custom code there, i just submitChanges on the model and get the response, thats it.

@jeremycoppey
Copy link
Author

SAP UI version: 1.96

I don't get in Line 83:

catch (error) {
        Log.error(error);
}

This is because I get a success on line 73 and not an error on line 76
success: data => { resolve(data); },

@marianfoo
Copy link
Member

i was able to recreate it.
You´re right, it does respond with sucess, but FE displays my error.
The showBackendErrorMessages is default false

So it is a bug because in a Freestyle scenario it would not display the error.

image

@jeremycoppey
Copy link
Author

jeremycoppey commented Nov 17, 2023

Fixed it temporary with this little "hack"

openSpreadsheetUploadDialog: async function (oEvent) {
			this.getView().setBusyIndicatorDelay(0)
			this.getView().setBusy(true)
			this.spreadsheetUpload = await this.getView().getController().getOwnerComponent().createComponent({
				usage: "spreadsheetImporter",
				async: true,
				componentData: {
					context: this,
					tableId:"comxxxxx.tagmanager::sap.suite.ui.generic.template.ListReport.view.ListReport::ZTG_C_TAG_M--responsiveTable-CONDITION",
					mandatoryFields: ["TagId", "CompanyCode","ObjectTypeId"],
					showBackendErrorMessages: true,
					debug: true
				}
			});
			this.spreadsheetUpload.openSpreadsheetUploadDialog()
			this.spreadsheetUpload.attachRequestCompleted((event) => {
				if(!event.getParameter("success")){
					if(sap.ui.getCore().getMessageManager().getMessageModel().oData){
						event.getSource().spreadsheetUpload.getODataHandler().odataMessageHandler.displayMessages();
					}
				}				
			}, this);
			this.getView().setBusy(false)
		}`

This part is where the magic happens

`this.spreadsheetUpload.attachRequestCompleted((event) => {
	if(!event.getParameter("success")){
		if(sap.ui.getCore().getMessageManager().getMessageModel().oData){
			event.getSource().spreadsheetUpload.getODataHandler().odataMessageHandler.displayMessages();
		}
	}				
}, this);

@marianfoo
Copy link
Member

marianfoo commented Dec 15, 2023

Was able to recreate in on Version 1.96.23, not on version 1.120 with OData V2 and triggering a 400 Error with CAP.
Unfortunately the submitChanges does not respond with and error so the variable this.submitChangesResponse is empty.
When i check for errors to show the error dialog here, it will skip and not show the error.

It will throw and error when waiting for the create Promises here and called here in OData.ts.

A solution would be to try/catch the await this.waitForCreation(); and just show the error dialog.
Maybe also check sap.ui.getCore().getMessageManager().getMessageModel().

Triggering the 400 in CAP:

	init() {
		const { "Orders.Items": OrderItems } = this.entities;
		this.before('CREATE', OrderItems, (req) => {
			// Implement your validation logic here
			// For example, check if a required field is missing

			  // Throw a 400 Bad Request error if validation fails
			  req.error(400, 'Some important field is missing');
			
		  });

		return super.init();
	}

@marianfoo
Copy link
Member

Hi @jeremycoppey
can you have a look at #426 and give me your opinion if that could help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants