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

Missing null check in InternalLoadFile #46

Open
rmunn opened this issue Jun 11, 2022 · 0 comments
Open

Missing null check in InternalLoadFile #46

rmunn opened this issue Jun 11, 2022 · 0 comments

Comments

@rmunn
Copy link

rmunn commented Jun 11, 2022

In the LfMerge build for the fieldworks8-master (and -qa and -live) branch(es), I've gotten repeated build failures when a network hiccup causes the connection to TeamCity to be terminated early, without any files having been downloaded. I just re-run the affected GitHub Actions workflow, and it often fails a second or third time, but eventually succeeds with no code or configuration changes. https://github.com/sillsdev/LfMerge/actions/runs/2473715799/attempts/1 is one recent example. If you click through to the failed build, you'll see the ultimate error was "System.ArgumentNullException: Value cannot be null. error MSB4018: Parameter name: source, at System.Linq.Enumerable.TryGetFirst, at System.Linq.Enumerable.FirstOrDefault, at BuildDependency.DependencyFile.InternalLoadFile".

I've looked at the InternalLoadFile source, and I believe the problem is this line:

if (config != null)
{
var projects = await projectsTask;
var proj = projects.FirstOrDefault(project => project.Id == config.ProjectId);

Note how projects is used immediately without checking whether it is null. I believe this line is the source of the problems I've been having recently in the LfMerge build.

However, I don't think it's quite so simple as checking whether projects is null. Because the reason why projects could be null should be addressed. In this case, it's (I believe but can't prove) because of a temporary network error while talking to TeamCity, and therefore the right answer is to retry a few times before giving up. And that part, I'm not familiar enough with the code to write. I could submit a PR with a null check easily enough, but making it retry in the face of network hiccups is something you would be able to implement much faster than I could.

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

1 participant