tcplugins / tcWebHooks

WebHooks plugin for Teamcity. Supports many build states and payload formats.
https://netwolfuk.wordpress.com/category/teamcity/tcplugins/tcwebhooks/
157 stars 30 forks source link

Getting Error :"the server responded with a status of 403 ()" when adding new webhook template #160

Closed AnkitGupta142 closed 4 years ago

AnkitGupta142 commented 4 years ago

Expected Behavior

I should be able to add a new template in the webhook template on click of AddNewTemplate button.

Current Behavior

Whenever I am adding any new template from AddNewTemplate button , I am getting a popup mentioning "object object". On inspecting it I can see in the console that I am getting "Failed to load resource: the server responded with a status of 403 ()" error.

Steps to Reproduce (for bugs)

  1. Go to the webhook template page.

  2. Click on addNewTemplate button. WebHook2 TCWebHook

  3. Fill all the necessary details. 4.Click on save .

Your Environment

netwolfuk commented 4 years ago

Hi @AnkitGupta142 Are you an administrator in TeamCity?

At the moment, you need to be admin to create or edit templates.

The alpha 4 release of 1.2.0 added support for project templates.

ryanclanigan commented 4 years ago

I'm seeing this as well on both the latest 1.1 release and the latest 1.2 release.

Any attempt to add a new template fails with the following error:

Responding with error, status code: 404 (Not Found).\nDetails: com.sun.jersey.api.NotFoundException: null for uri: http://xxxx.com:443/app/rest/webhooks/templates/YYYY\nPlease check URL is correct.
netwolfuk commented 4 years ago

Thanks @ryanclanigan. Have you previously created templates successfully? I presume you're a TeamCity administrator for 1.1, or have edit project permission for 1.2. Is that correct?

Also, which TeamCity version are you running?

ryanclanigan commented 4 years ago

Yes, I am a project administrator. I've not created templates before, as I literally just installed the plugin.

TeamCity Enterprise 2020.1 (build 78475)

netwolfuk commented 4 years ago

@ryanclanigan Do you have the tcWebHook REST API installed? You're getting 404, which means the endpoint is not there. Where as Ankit was getting 403, which means permission denied.

netwolfuk commented 4 years ago

Assuming that's the cause, I could probably make the error more helpful.

ryanclanigan commented 4 years ago

I definitely have it installed. image

netwolfuk commented 4 years ago

Thanks for checking @ryanclanigan . Was YYYY the ID of your new template?

Can you try loading the main templates page and see if it was created?

ryanclanigan commented 4 years ago

Yes it was the name, and no it was not created.

However, for some reason, I was able to make a new template by doing the exact same thing I thought I did earlier, by clicking on the new template button in the templates section.

Could a TC server restart maybe have fixed something?

netwolfuk commented 4 years ago

was able to make a new template

Great!

doing the exact same thing I thought I did earlier

Hmm. Weird. I was half hoping that we could reproduce it with some debugging of the REST requests by looking at the Network tab in the browser.

Could a TC server restart maybe have fixed something?

TL;DR Quite likely.

Back in the day, some jars in my REST plugin conflicted with some jars in TeamCity's REST plugin (mine actually extends theirs as I don't want to have to re-invent all their stuff). This meant some code had to run to clean up the jars, and then a restart was required immediately. However, that has been resolved since about 2019.1, and a restart is no longer required. I have to restart mine, because I am always updating, never really installing from scratch, and because support for hot-reloading plugins is fairly new, I can't support it for users running TC9 and 10 (it actually stops the plugin from loading due to a syntax error in the plugin config file).

However, installing it seems to allow hot-reloading somehow and this might cause an issue. Did you restart after the plugin was installed?

netwolfuk commented 4 years ago

Thanks @AnkitGupta142 The error handling had improved in 1.2, but I'll check this case.

George-A commented 2 years ago

Had the same problem. Fixed by restarting teamcity.

netwolfuk commented 2 years ago

Thanks @George-A

Could you please let me know which TeamCity and tcWebHooks versions you're running?

patroeper commented 2 years ago

FWIW, I ran into this today after installing both plugins (Web Hooks + Web Hooks REST API) when creating my first template as an admin. The errors match what has already been reported ([object Object] browser prompt + 403/404 responses). Restarting TeamCity was my fix.

Versions:

Web Hooks (tcWebHooks)
- Branch: 1.1.x.x
- Revision: 99409d2
1.1.374.403

Web Hooks REST API (tcWebHooks)
- Branch: 1.1.x.x
- Revision: 99409d2
1.1.374.403

TeamCity Professional 2021.2.3 (build 99711)

Nice work on the plugin @netwolfuk. I wasn't expecting the feature richness; previewing a template on past builds was pretty sweet! 👏

netwolfuk commented 2 years ago

Thanks for the feedback @patroeper I'll do some more investigation on whether it's possible to force a reboot on plug-in install or - better yet - whether I can actually fix the underlying cause.