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

Save failed: {"count":1,"value":{"Message":"Value cannot be null #115

Closed
prashanthbv12 opened this issue Apr 1, 2020 · 25 comments
Closed

Comments

@prashanthbv12
Copy link

Hello I downloaded latest release, Did all steps correctly. No errors now either in service hook or in Azure portal logs.(200 result code)
When i run the simple below rule which is used to work in earlier release is not working now. It is giving below error when i deep dive into logs.

Save failed: {"count":1,"value":{"Message":"Value cannot be null."}}

Rule

.language=Csharp
if (self.WorkItemType == "Test Case")
{
self["Test Method id"] = self["System.Id"];
}
return "Nothing to do";

@prashanthbv12 prashanthbv12 added the bug Something isn't working label Apr 1, 2020
@mmuresan
Copy link
Contributor

mmuresan commented Apr 3, 2020

I also get the same error on all of my rules.
They all work when I dryrun them locally or connected to DevOps, but all fail when I put them in the Aggregator.

@giuliov
Copy link
Member

giuliov commented Apr 3, 2020

I will do some tests over the weekend.
In the meantime, have you checked if there are mandatory fields that you are not setting?

@prashanthbv12
Copy link
Author

prashanthbv12 commented Apr 3, 2020 via email

@mmuresan
Copy link
Contributor

mmuresan commented Apr 3, 2020

This is happening even in the rules where I try setting up only the State of the some items.
So, no required fields are involved in this.

@mmuresan
Copy link
Contributor

mmuresan commented Apr 3, 2020

When I dryrun it locally or connected to DevOps, there are no errors.
These are some of the rules that I use and get error when I change something in DevOps.
CreateNewPBIForFeature.rule.txt
CreateNewTestTaxForBug.rule.txt
UpdateFeatureState.rule.txt
UpdatePBIState.rule.txt
CreateNewFixTaxForBug.rule.txt

@giuliov
Copy link
Member

giuliov commented Apr 4, 2020

In my tests, I was able to found only one issue (#116). I suggest to drop the existing mappings and recreate the instance from scratch.

@giuliov giuliov added the wontfix This will not be worked on label Apr 4, 2020
@mmuresan
Copy link
Contributor

mmuresan commented Apr 4, 2020

I already removed the whole Azure set of object multiple times from Azure directly.
Using this current version I reinstalled multiple times, using the normal installation procedure specified in aggregator-cli.
I also unmapped and removed all the rules and then re-registered them and remapped them countless times after recreating the aggregator instance.
I am following by the book all installation, registration and mapping procedures.
Listing the rules works fine. I can also see them in the installed Azure function.
Listing the mappings also shows all mappings correctly. I can see all the webhooks in Azure DevOps and they are setup correctly.

Unfortunately, running any rules always gives me the same kind of errors, no matter what rule gets triggered, either when it requires modifying any fields in Azure DevOps, or if requires creating a new Work Item.

There is definitely something wrong either:
A. with the installation part of the aggregator-cli, by not setting correctly the functions
or
B. with the rules engine, when running them
I attached above some of my significant rules.
Can anybody please test with any one of them?

@stale stale bot removed the wontfix This will not be worked on label Apr 4, 2020
@giuliov
Copy link
Member

giuliov commented Apr 4, 2020

Have you tried removing any FunctionRuntime.zip file lingering around?

@mmuresan
Copy link
Contributor

mmuresan commented Apr 4, 2020

I apologize. I'm still a beginner with this aggregator app. Where should I look for that file? In Azure?

@giuliov
Copy link
Member

giuliov commented Apr 4, 2020

It is cached locally and the wrong version may take precedence

@mmuresan
Copy link
Contributor

mmuresan commented Apr 4, 2020

I found that and removed it. While installing a new instance, I get a message (among other messages):
Cannot read aggregator-manifest.ini: Not Found
Should I ignore it or this is important to have locally?

@giuliov
Copy link
Member

giuliov commented Apr 4, 2020

It is ok when appears the first time you create the instance

@prashanthbv12
Copy link
Author

prashanthbv12 commented Apr 4, 2020 via email

@BobSilent
Copy link
Collaborator

Hello I downloaded latest release, Did all steps correctly. No errors now either in service hook or in Azure portal logs.(200 result code)
When i run the simple below rule which is used to work in earlier release is not working now. It is giving below error when i deep dive into logs.

Save failed: {"count":1,"value":{"Message":"Value cannot be null."}}

Rule

.language=Csharp
if (self.WorkItemType == "Test Case")
{
self["Test Method id"] = self["System.Id"];
}
return "Nothing to do";

in this line:

self["Test Method id"] = self["System.Id"];

  1. can you please use self.Id instead of self["System.Id"], i think the field id cannot be accessed via the reference name
  2. are you sure the reference name of the field is Test Method id normally it does not have blanks in the reference name. can you try to replace this by e.g. self.History = self.Id;

@BobSilent
Copy link
Collaborator

When I dryrun it locally or connected to DevOps, there are no errors.
These are some of the rules that I use and get error when I change something in DevOps.
CreateNewPBIForFeature.rule.txt
CreateNewTestTaxForBug.rule.txt
UpdateFeatureState.rule.txt
UpdatePBIState.rule.txt
CreateNewFixTaxForBug.rule.txt

at least in this rule CreateNewPBIForFeature.rule
i see this line:

newChild.Description = parent.Description;

when saving a work item you do not need to add a value for description, therefore the field can be empty/null.
With the code line, you assign the null value to your new work item, which can cause the error.
please try this
newChild.Description = parent.Description ?? string.Empty;

@mmuresan
Copy link
Contributor

mmuresan commented Apr 6, 2020

Looking through the documentation, I couldn't find how to set a custom field.
For example if I want to set a custom field named "Created In", how do I read and how do I write that in the work item?

@BobSilent
Copy link
Collaborator

BobSilent commented Apr 6, 2020

just for completeness: a PR is available, please see #118
Thanks @mmuresan

@mmuresan
Copy link
Contributor

mmuresan commented Apr 6, 2020

Cool. That showed me how to do it. Thx

@prashanthbv12
Copy link
Author

prashanthbv12 commented Apr 7, 2020

2. re you sure the reference name of the field is Test Method id normally it does not have blanks in the reference name. can you try to replace this by e.g. self.Histo

.language=C#
if (self.WorkItemType == "Test Case")
{ 
  self["Custom.TestMethodId"] = self.Id;
}
return "Nothing to do";

I changed like this as you said above. but in text method ID field I am getting System.Collections.Generic.Dictionary`2[System.String,System.Object] instead of systemd ID getting copied.

@BobSilent
Copy link
Collaborator

i see can you try with self["Custom.TestMethodId"] = self.Id.Value;

@prashanthbv12
Copy link
Author

i see can you try with self["Custom.TestMethodId"] = self.Id.Value;

Worked!!!!I feel 10 years younger now.
Thanks Bob :)

@BobSilent
Copy link
Collaborator

I provided a fix for the ugly syntax, so that in future you can simply use self["Custom.TestMethodId"] = self.Id;

So is there anything open from your initial issue?

@BobSilent BobSilent removed the bug Something isn't working label Apr 7, 2020
@prashanthbv12
Copy link
Author

prashanthbv12 commented Apr 7, 2020 via email

@BobSilent
Copy link
Collaborator

Maybe just one remark which came into my mind.

You cannot use .Id on a new created work item in your code, as the item gets its id during save, and the save will be done after rule code is completely executed.

@BobSilent
Copy link
Collaborator

@mmuresan please open a new issue if there is anything open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants