tfsaggregator / tfsaggregator-webhooks

WARNING: the team is no more maintaing this version. See aggreggator-cli instead.
https://github.com/tfsaggregator/aggregator-cli
19 stars 22 forks source link

Object reference not set to an instance of an object. (500) #11

Closed Crashdummyy closed 6 years ago

Crashdummyy commented 6 years ago

Hey There,

My Webhook responds everytime with ( Object reference not set to an instance of an object. (500) ) Exception.

How can that Exception be thrown?

` var userStory = self.Parent;

            userStory["Microsoft.VSTS.Scheduling.CompletedWork"] =
                userStory.Children.Sum(task => task.GetField<double>("Microsoft.VSTS.Scheduling.CompletedWork", 0d));
            userStory["Microsoft.VSTS.Scheduling.OriginalEstimate"] =
                userStory.Children.Sum(taskk => taskk.GetField<double>("Microsoft.VSTS.Scheduling.OriginalEstimate", 0d));

`

The Code is very Simple and even provides an default Value.

jessehouwing commented 6 years ago

I suspect the item doesn't have a parent. Thus self.parent is null.

On Nov 24, 2017 13:08, "Simon" notifications@github.com wrote:

Hey There,

My Webhook responds everytime with ( Object reference not set to an instance of an object. (500) ) Exception.

How can that Exception be thrown?

` var userStory = self.Parent;

        (double)userStory["Microsoft.VSTS.Scheduling.CompletedWork"] =
            userStory.Children.Sum(task =>

task.GetField("Microsoft.VSTS.Scheduling.CompletedWork", 0d)); (double)userStory["Microsoft.VSTS.Scheduling.OriginalEstimate"] = userStory.Children.Sum(taskk => taskk.GetField("Microsoft.VSTS.Scheduling.OriginalEstimate", 0d));

`

The Code is very Simple and even provides an default Value.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tfsaggregator/tfsaggregator-webhooks/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-uSwSmBkmY9gjEBCTqh9PgihmuFiSpks5s5rG6gaJpZM4Qpvdu .

Crashdummyy commented 6 years ago

it does have a Parent. And the Code does what it should.

The only Problem is that it throws this Error.

I will try again with checking for parent

giuliov commented 6 years ago

remove the (double) cast

Crashdummyy commented 6 years ago

Don't know if that was the Problem ( will not find out :smile: ) I'm additionally checking the Parent for the Valid field ( if there is no Parent, there is no valid field of course ).

Code Seems to work fine now

Crashdummyy commented 6 years ago

The Double Cast was already removed before Casting has led me to false results, too.

jessehouwing commented 6 years ago

It should be relatively easy to add a validation wrapper for getfield to log additional debug data when requesting a field that doesn't exist. Then log the work item type you're actually inspecting.

On Nov 24, 2017 1:24 PM, "Simon" notifications@github.com wrote:

Closed #11 https://github.com/tfsaggregator/tfsaggregator-webhooks/issues/11.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tfsaggregator/tfsaggregator-webhooks/issues/11#event-1357065396, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-uS8AhVoWoCgVUJOdDpwNzSMQF5hWKks5s5rV2gaJpZM4Qpvdu .

Crashdummyy commented 6 years ago

You're Right should have done that already :/ Because that "Workaround" I did won't work for an additional Custom field. TF26027: A field definition Microsoft.VSTS.Scheduling.StoryPoints in the work item type definition file does not exist. Add a definition for this field or remove the reference to the field and try again. (500)

Is the next Error so I need to add some getField Validators. Will do that on monday ;)