I’m trying to add config as code for the first time to an established Octopus project into an established (enterprise) GitHub repo. When I attempt this, I get a “Sequence contains no matching element” error. Octopus server version is 2022.1.2495.
I was able to create a simple dummy Octopus project, with a single powershell step to write-host, and successfully added it to a new GitHub repo, so I know there’s nothing wrong with my GitHub connectivity
Stack trace from log:
2022-05-24 10:34:13.4664 3992 72 INFO git-op on P25MUQG4DNTWWAR2UZICO2J6MRJKJAWV root: Getting all branches
2022-05-24 10:34:14.9031 3992 59 INFO "HTTPS" "GET" to "<REDACTED URL>""/api/serverstatus/health" completed with 200 in 00:00:00.0171325 (017ms) by "<REDACTED USER>"
2022-05-24 10:34:18.3643 3992 84 WARN Only the last project path should be popped.
2022-05-24 10:34:18.9201 3992 82 ERROR Unhandled error on request: "Sequence contains no matching element"
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Octopus.Core.Git.Repositories.RepositoryRoot.EnsureLocalBranchesAreCurrent(Repository repository, String remoteName, String[] branchRefSpecs) in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 381
at Octopus.Core.Git.Repositories.RepositoryRoot.<>c__DisplayClass31_0.<EnsureRepositoryIsCurrent>b__0() in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 315
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Octopus.Core.Git.Repositories.RepositoryRoot.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 326
at Octopus.Core.Git.Repositories.ErrorHandlingRepositoryRootDecorator.<EnsureRepositoryIsCurrent>b__16_0(CancellationToken ct) in ./source/Octopus.Core/Git/Repositories/ErrorHandlingRepositoryRootDecorator.cs:line 63
at Octopus.Core.Git.Repositories.ErrorHandlingRepositoryRootDecorator.HandleLibGit2SharpExceptions(Func`2 action, String defaultErrorMessage, CancellationToken cancellationToken, List`1 statusErrorList) in ./source/Octopus.Core/Git/Repositories/ErrorHandlingRepositoryRootDecorator.cs:line 97
at Octopus.Core.Git.Repositories.ErrorHandlingRepositoryRootDecorator.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/ErrorHandlingRepositoryRootDecorator.cs:line 62
at Octopus.Core.Git.Repositories.FileSystemLoggingRepositoryRootDecorator.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/FileSystemLoggingRepositoryRootDecorator.cs:line 71
at Octopus.Core.Git.Repositories.SpaceLimitRepositoryRootDecorator.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/SpaceLimitRepositoryRootDecorator.cs:line 62
at Octopus.Core.Git.Repositories.GitRepository.PrepareWorkTree(GitRef gitRef, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/GitRepository.cs:line 123
at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
at Octopus.Core.Extensions.TaskExtensionMethods.AsSync[T](Task`1 task) in ./source/Octopus.Core/Extensions/TaskExtensionMethods.cs:line 22
at Octopus.Core.Persistence.Git.GitTransactionFactory.BeginOrAdoptExisting() in ./source/Octopus.Core/Persistence/Git/GitTransactionFactory.cs:line 55
at Octopus.Core.Persistence.Git.GitPersistenceModule.<>c.<Load>b__6_2(IComponentContext c) in ./source/Octopus.Core/Persistence/Git/GitPersistenceModule.cs:line 97
at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass0_0`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p)
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
Hi Mark,
Welcome to the Octopus forum.
Sorry to see you running into this config-as-code issue.
It seems this issue you have has been identified by our config-as-code team and they are currently working on the fix.
You can subscribe to the GH issue here:
I note there is a workaround if you are willing to try it:
Thanks to your support team we were able to resolve this by manually clearing the \Git folder (which required that we restart the Octopus service because some files in that folder were locked). But after clearing the folder Octopus UI was fixed.
I tried the workaround steps of clearing the \Git directory. This did not work.
The issue seems to be related to the GitHub repository rather than the Octopus project. I cloned the Octopus project, and created a new GitHub Repo. I then added config as code of the cloned project to the newly created repo and it worked. However, this isn’t a solution for me as I still need to be able to add the config to my existing legacy GitHub repo. The legacy GitHub repo has been around for a long time, and has many branches/tags, so I don’t know if it is a contributing cause.
Hi Mark
It appears that this fix is available now in this version:
There are still some questions around if this will fix every instance of this error but the team have added additional logging to pin down any remaining issues that occur.
If you have capacity to update to this version that would be very helpful and may in fact fix the issue for you. If not we will have a much clearer outline of what the problem is.