TF51005: The query references a field that does not exist

By | 2011-05-24T13:40:05+00:00 May 24th, 2011|Visual Studio Team Foundation Server|1 Comment

So, I was uploading a process template the other day and got this error and could not figure out the reason why for the life of me:

2011-05-24T11:14:55 | Module: Work Item Tracking | Thread: 29 | The following query was found in C:UsersxxxxxxxAppDataLocalTempTPW_tmpA576.tmpWorkItem TrackingQueriesIteration1Backlog.wiq: Iteration 1/Iteration Backlog
---begin Exception entry---
Time: 2011-05-24T11:14:55
Module: Engine
Event Description: TF30162: Task "Queries" from Group "WorkItemTracking" failed
Exception Type: Microsoft.TeamFoundation.Client.PcwException
Exception Message: Team Foundation Server encountered an error creating the query Iteration 1/Iteration Backlog from C:UsersxxxxxxxAppDataLocalTempTPW_tmpA576.tmpWorkItem TrackingQueriesIteration1Backlog.wiq
Stack Trace:
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Execute(ProjectCreationContext ctxt, XmlNode taskXml)
 at Microsoft.VisualStudio.TeamFoundation.ProjectCreationEngine.TaskExecutor.PerformTask(IProjectComponentCreator componentCreator, ProjectCreationContext context, XmlNode taskXml)
 at Microsoft.VisualStudio.TeamFoundation.ProjectCreationEngine.RunTask(Object taskObj)
--   Inner Exception   --
Exception Message: Team Foundation Server encountered an error creating the query Iteration 1/Iteration Backlog from C:UsersxxxxxxxAppDataLocalTempTPW_tmpA576.tmpWorkItem TrackingQueriesIteration1Backlog.wiq (type WitPcwFatalException)
Exception Stack Trace:    at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.QueryTask.AddQuery(String name, String fileName, String path, QueryFolder parent)
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.QueryTask.ParseQuery(XmlNode node, String parentPath, QueryFolder parent, Boolean execute)
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.QueryTask.ParseQueryFolder(XmlNode node, String parentPath, QueryFolder parent, Boolean execute)
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.QueryTask.Parse(Boolean execute)
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.QueryTask.Execute()
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Parse(ContextWrapper wrapper, XmlNode taskXml, Boolean fExecute)
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Execute(ProjectCreationContext ctxt, XmlNode taskXml)
Inner Exception Details:
Exception Message: TF51005: The query references a field that does not exist. The error is caused by «[System.TeamProject]». (type InvalidQueryTextException)
Exception Stack Trace:    at Microsoft.TeamFoundation.WorkItemTracking.Client.StoredQuery.ValidateWiql(WorkItemStore store, String queryText)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.QueryDefinition.SetQueryTextWithValidation(String queryText)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.QueryDefinition..ctor(String name, String queryText, QueryFolder parent)
 at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.QueryTask.AddQuery(String name, String fileName, String path, QueryFolder parent)
Inner Exception Details:
Exception Message: TF51005: The query references a field that does not exist. (type SyntaxException)
Exception Stack Trace:    at Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.NodeFieldName.Bind(IExternal e, NodeTableName tableContext, NodeFieldName fieldContext)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.NodeCondition.Bind(IExternal e, NodeTableName tableContext, NodeFieldName fieldContext)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.Node.BindChildren(IExternal e, NodeTableName tableContext, NodeFieldName fieldContext)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.NodeAndOperator.Bind(IExternal e, NodeTableName tableContext, NodeFieldName fieldContext)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.Node.BindChildren(IExternal e, NodeTableName tableContext, NodeFieldName fieldContext)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.NodeAndOperator.Bind(IExternal e, NodeTableName tableContext, NodeFieldName fieldContext)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.NodeSelect.Bind(IExternal e, NodeTableName tableContext, NodeFieldName fieldContext)
 at Microsoft.TeamFoundation.WorkItemTracking.Client.StoredQuery.ValidateWiql(WorkItemStore store, String queryText)
--- end Exception entry ---

This is the query that the upload was failing on was the following:

  SELECT [System.Id],
 [System.WorkItemType],
 [System.Title],
 [xxxx.Finance.ActivityID],
 [System.State],
 [System.AssignedTo],
 [Microsoft.VSTS.Scheduling.RemainingWork],
 [Microsoft.VSTS.Scheduling.CompletedWork],
 [Microsoft.VSTS.Scheduling.StoryPoints],
 [Microsoft.VSTS.Common.StackRank],
 [Microsoft.VSTS.Common.Priority],
 [System.IterationPath],
 [System.AreaPath]
 FROM WorkItemLinks
 WHERE ([System.TeamProject] = @project
 AND  [System.AreaPath] UNDER @project
 AND  [System.IterationPath] UNDER '$$PROJECTNAME$$Iteration 1'
 AND (
 [System.WorkItemType] = 'User Story'
 OR [System.WorkItemType] = 'Bug'
 OR [System.WorkItemType] = 'Task'
 OR [System.WorkItemType] = 'Compliance'
 )
 )
 AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
 AND [Target].[System.WorkItemType] = 'Task'
 ORDER BY [Microsoft.VSTS.Common.StackRank], [Microsoft.VSTS.Common.Priority]
 mode(Recursive)

The error, it turns out, is invalid and if you try to track it down you’ll be hopelessly disappointed. The problem is that this is a hierarchical query and because of copy and paste issues I inadvertently removed the “[Source]. value that is required before the names of the fields in the filter. The correct query should look like the following:

SELECT [System.Id],
 [System.WorkItemType],
 [System.Title],
 [xxxx.Finance.ActivityID],
 [System.State],
 [System.AssignedTo],
 [Microsoft.VSTS.Scheduling.RemainingWork],
 [Microsoft.VSTS.Scheduling.CompletedWork],
 [Microsoft.VSTS.Scheduling.StoryPoints],
 [Microsoft.VSTS.Common.StackRank],
 [Microsoft.VSTS.Common.Priority],
 [System.IterationPath],
 [System.AreaPath]
 FROM WorkItemLinks
 WHERE ([Source].[System.TeamProject] = @project
 AND [Source].[System.AreaPath] UNDER @project
 AND  [Source].[System.IterationPath] UNDER '$$PROJECTNAME$$Iteration 1'
 AND (
 [Source].[System.WorkItemType] = 'User Story'
 OR [Source].[System.WorkItemType] = 'Bug'
 OR [Source].[System.WorkItemType] = 'Task'
 OR [Source].[System.WorkItemType] = 'Compliance'
 )
 )
 AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
 AND [Target].[System.WorkItemType] = 'Task'
 ORDER BY [Microsoft.VSTS.Common.StackRank], [Microsoft.VSTS.Common.Priority]
 mode(Recursive)

About the Author:

One Comment

  1. Martin Hinshelwood May 24, 2011 at 9:08 pm

    Jeff, this just goes to show that copy and paste is bad!

Leave A Comment