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

Override JsonParseExceptionMapper and JsonMappingExceptionMapper #173

Closed
grigoriev opened this issue Aug 28, 2024 · 0 comments · Fixed by SchweizerischeBundesbahnen/ch.sbb.polarion.extension.generic#146
Labels
bug Something isn't working

Comments

@grigoriev
Copy link
Contributor

Current Behavior

JacksonFeature registers JsonParseExceptionMapper and JsonMappingExceptionMapper which returns 400 Bad Request as plain/text and does not allow to override them to return application/json.

Expected Behavior

We need to find the way to override them to return errors in JSON

Steps To Reproduce

for example in JavaScript:

    saveWebhooks: function () {
        SbbCommon.hideActionAlerts();

        const webhookRows = Array.from(document.querySelectorAll('#webhooks-table tr'));
        const webhookConfigs = webhookRows
            .map(row => {
                return {
                    url: row.querySelector('input[name="url"]')?.value,
                    authType: row.querySelector('input[name="auth_type"]')?.value,
                    authTokenNameWRONG_NAME: row.querySelector('input[name="auth_token_name"]')?.value
                };
            });

        SbbCommon.callAsync({
            method: 'PUT',
            url: `/polarion/${SbbCommon.extension}/rest/internal/settings/${SbbCommon.setting}/names/${Configurations.getSelectedConfiguration()}/content?scope=${SbbCommon.scope}`,
            contentType: 'application/json',
            body: JSON.stringify({
                'webhookConfigs': webhookConfigs,
            }),
            onOk: () => {
                SbbCommon.showSaveSuccessAlert();
                SbbCommon.setNewerVersionNotificationVisible(false);
                Configurations.loadConfigurationNames();
            },
            onError: () => SbbCommon.showSaveErrorAlert()
        });
    }

returns

Unrecognized field "authTokenNameWRONG_NAME" (class ch.sbb.polarion.extension.pdf.exporter.rest.model.settings.webhooks.WebhookConfig), not marked as ignorable (3 known properties: "authType", "authTokenName", "url"])
 at [Source: (String)"{"webhookConfigs":[{"url":"asd1","authType":"","authToken":""},{"url":"asd2","authType":"","authToken":""}]}"; line: 1, column: 61] (through reference chain: ch.sbb.polarion.extension.pdf.exporter.rest.model.settings.webhooks.WebhooksModel["webhookConfigs"]->java.util.ArrayList[0]->ch.sbb.polarion.extension.pdf.exporter.rest.model.settings.webhooks.WebhookConfig["authToken"])

Environment - OS

Any

Polarion version

2404

Extension Version

6.1.0

Anything else

No response

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