tfsaggregator / aggregator-cli

A new version of Aggregator aiming at Azure DevOps (ex Visual Studio Team Services)
https://tfsaggregator.github.io/
Apache License 2.0
74 stars 32 forks source link

Error with retrieve a workitem with attachment #99

Closed adu80 closed 4 years ago

adu80 commented 4 years ago

image

Occurs when a workitem have a relation to an attachment.

aggregator.Engine.WorkItemRelationWrapper.WorkItemRelationWrapper(string relationUrl)

var id = int.Parse(relationUri.Segments.Last());
LinkedId = new PermanentWorkItemId(id);

In this case, the last segment is not an integer but a guid.

I proposed this fix (before to do a wrong pull request >.<) :

aggregator.Engine.WorkItemRelationWrapperCollection.WorkItemRelationWrapperCollection(WorkItemWrapper workItem, IList<WorkItemRelation> relations)

_original = relations == null
                        ? new List<WorkItemRelationWrapper>()
                        : relations.Where(relation => 
                                            !relation.Rel.Equals("ArtifactLink") 
                                            && !relation.Rel.Equals("AttachedFile")
                                            && !relation.Rel.Equals("Hyperlink"))
                                   .Select(relation => new WorkItemRelationWrapper(relation))
                                   .ToList();
BobSilent commented 4 years ago

This looks like a fix. I am struggling a little bit with it due to #89 and also as the WorkItemRelationWrapperCollection currently has an AddHyperlink Method, which makes this a little bit strange in using: you do not get the already linked hyperlinks, but you could add some.

Nevertheless I am not happy in total with the overall handling in the implementation here today. As I started for #88 and also facing some limitations in relation handling.

But, to have a quick fix here i would currently thinking more about something like that

aggregator.Engine.WorkItemRelationWrapper.WorkItemRelationWrapper(string relationUrl)

var idName = relationUri.Segments.Last();
var id = int.TryParse(idName, out var i) ? i : (int?)null;
LinkedId = id == null ? null : new PermanentWorkItemId(id.Value);

in a next step i will have a deeper look about how #88 and #89 can get together in a simple and easy way

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.