Bitbucket feature branches and config as code

I recently switched some projects to use config as code, but I am unable to select a branch other than master or develop. All of my feature branches give this error:

Looking at the chrome dev tools the response is a 404 with this message: “ErrorMessage”: “The resource you requested was not found.”

I am using bitbucket and have added a generic user with admin access to the repo.

To be clear, the other branches show up in the dropdown, but when I select anything other than develop or master I get the error above.

I am using v2022.1 (Build 2133)

Any ideas?

Hi @ksheffer,

Welcome to the Octopus community! I’m sorry to see that you’re hitting this issue with your version-controlled project.

Typically when we see errors like this associated with config as code it can be resolved by clearing the local Git cache (Configuration > Git > Clear Local Cache)

We do have one open bug for the cache clearing to take into consideration. If you find this option has not resolved your error you can manually delete any files and folders within the Git directory on your server (default C:\Octopus\Git) and hit the Clear Local Cache button again in the UI.

Hopefully this helps, but if not let us know and we will continue to help you troubleshoot.

Thanks!
Dan

Thanks Dan,

I just finished following your instructions. I ended up stopping the Octopus service on the server since some files wouldn’t delete in C:\Octopus\Git because they were in use. After it came back up, I hit Clear Local Cache in the UI again, but I am still seeing the same issue. I can load the deployment process on develop or master, but I can’t choose any other branch.

I think I know what the bug is. All of our other branches follow a branching scheme of feature/, bugfix/. I think this is a serialization issue of the “/” in the branch name. I just tested this theory by creating another branch without using our convention and I’m able to load it in Octopus.

Here is an example of the url that returns a 404: https:///api/Spaces-1/projects/Projects-470/git/branches/feature%2Fnet6-upgrade - the branch name is feature/net6-upgrade.

Looks like this issue was already caught and handled Git ref validation fails when branch contains a `/` character · Issue #7486 · OctopusDeploy/Issues · GitHub. I’ll upgrade my Octopus version and that should fix it.

1 Like

Hi @ksheffer,

Great catch on the branch name causing the issue! For your reference, here is the ticket we created for the issue you saw clearing the local cache.

Please let us know if you need anything else.

Thanks!
Dan

1 Like

Upgraded to version 2022.1 Build 2474 and I’m still getting the same error when trying to load a branch with a ‘/’ in the name.

Hi @ksheffer,

That’s unfortunate that you’re still seeing this error after upgrading. If you haven’t already, can you attempt to clear the local Git cache again to see if it has any impact? I suspect it won’t, but just want to make sure we check that step off.

I am going to see if I can reproduce this error on my instance. For troubleshooting purposes, it is probably best to get the logs from your Octopus instance. I will DM you a secure upload link you can use to upload your server logs to us.

Once you upload the logs just let me know as we do not get notified on our end. I look forward to hearing back and please let me know if you have any questions for me.

Thanks!

Hi @ksheffer,

I just wanted to get clarification on the issue you ran into attempting to delete the files and folders from C:\Octopus\Git. Once you stopped the Octopus service were you able to delete all of the contents of that directory or was there anything that you couldn’t delete? I just want to make sure that the folder was completely cleared out.

Thanks!
Dan

Hi @dan_close,

I thank you for your help in this. I did delete everything from C:\Octopus\Git on Friday and again today after the upgrade was finished.

I uploaded the most recent log file and made sure to reproduce it before grabbing it, so the bottom of the log file should have the most relevant info.

I think this is the relevant piece from the log (note that the branch I’m trying to access is “feature/net6-upgrade”):

2022-05-16 14:06:03.9113 5568 218 INFO “HTTP” “GET” to “localhost:8083"”/api/Spaces-1/projects/Projects-470/git/branches/feature/net6-upgrade" completed with 404 in 00:00:00.0089804 (008ms) by “Kevin Sheffer (ksheffer)”
2022-05-16 14:06:03.9113 5568 218 ERROR Unhandled error on request: “We received a request for a version-controlled resource on a non-version control route. Please use projects/{projectId}/{gitRef}/summary”
System.InvalidOperationException: We received a request for a version-controlled resource on a non-version control route. Please use projects/{projectId}/{gitRef}/summary
at Octopus.Server.Web.Middleware.ActionFilters.ProjectScopeResourceFilter.GetProjectPath(Project project, ResourceExecutingContext context) in ./source/Octopus.Server/Web/Middleware/ActionFilters/ProjectScopeResourceFilter.cs:line 114
at Octopus.Server.Web.Middleware.ActionFilters.ProjectScopeResourceFilter.TryExtractProjectRouteScope(ResourceExecutingContext context, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Middleware/ActionFilters/ProjectScopeResourceFilter.cs:line 100
at Octopus.Server.Web.Middleware.ActionFilters.ProjectScopeResourceFilter.ApplyToScope(ResourceExecutingContext ctx, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Middleware/ActionFilters/ProjectScopeResourceFilter.cs:line 61
at Octopus.Server.Web.Middleware.ActionFilters.ProjectScopeResourceFilter.OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next) in ./source/Octopus.Server/Web/Middleware/ActionFilters/ProjectScopeResourceFilter.cs:line 51
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
at Octopus.Server.Web.Infrastructure.Authentication.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult) in ./source/Octopus.Server/Web/Infrastructure/Authentication/AuthorizationMiddlewareResultHandler.cs:line 52
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.HttpOverrides.HttpMethodOverrideMiddleware.Invoke(HttpContext context)
at Octopus.Server.Web.UnitOfWorkMiddleware.InvokeAsync(HttpContext httpContext, IUnitOfWork unitOfWork) in ./source/Octopus.Server/Web/UnitOfWorkMiddleware.cs:line 47
at Octopus.Server.Web.UnitOfWorkMiddleware.InvokeAsync(HttpContext httpContext, IUnitOfWork unitOfWork) in ./source/Octopus.Server/Web/UnitOfWorkMiddleware.cs:line 47
at Octopus.Server.Web.Middleware.OctopusClientOldVersionWarningMiddleware.InvokeAsync(HttpContext context, IAutomationContext automationContext) in ./source/Octopus.Server/Web/Middleware/OctopusClientOldVersionWarningMiddleware.cs:line 53
at Octopus.Server.Web.Middleware.DynamicContentHeadersMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/DynamicContentHeadersMiddleware.cs:line 49
at Octopus.Server.Web.Middleware.MaintenanceModeMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/MaintenanceModeMiddleware.cs:line 61
at Octopus.Server.Web.Middleware.OctopusAuthenticationMiddleware.InvokeAsync(HttpContext context, CorrelationId correlationId) in ./source/Octopus.Server/Web/Middleware/OctopusAuthenticationMiddleware.cs:line 67
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Octopus.Server.Web.Middleware.LegacyRequestLoggerMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/LegacyRequestLoggerMiddleware.cs:line 42
at Octopus.Server.Web.Middleware.TelemetryMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/TelemetryMiddleware.cs:line 76
at Octopus.Server.Web.Middleware.ErrorHandlingMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/ErrorHandlingMiddleware.cs:line 96

Hi @ksheffer,

Thank you for sending that log over. I am going to reach out to our engineering team to get their input on this issue.

I believe this is somehow related to the local cache. In the logs I can see that several branches are having new cache folders created after the reset, however, I do not see the same entry for this specific branch. It’s also odd that the URL is not being formatted as we would expect which is causing the 404 error. Those two things may be related, but I’ll need to verify that. When I set up my own branch named feature/net6-upgrade my URL is formatted as /git/branches/feature%2Fnet6-upgrade which we would expect.

Our engineers are Australia based so I may not have any further updates until they are online later today. I will reach out with any updates or additional information they may need. In the meantime please let me know if you have any other questions for us.

Thanks!
Dan

Hi @dan_close,

Friday we upgraded to 2474 because we already had that version downloaded for another server and it was higher than the fix version on that issue I referenced earlier.

Today I upgraded to the latest (2584) and cleared the git cache multiple times, ensured the folder was empty, but I’m still having this issue.

In the Chrome debugger I see this as the http request (as before): Sign in to your account, but the logs don’t show the forward slash escaped.

We are hosting Octopus server on a windows vm, is that how you have your’s installed? I tried recycling the app pool and restarting the site in IIS. I also tried clearing my site cache in my browser. I’m not sure what else to clear that could be cache related.

Thanks,
Kevin

Hi @ksheffer,

My testing instance is also running on a Windows VM. The only big difference is that my projects are configured in GitHub rather than Bitbucket, however, that shouldn’t have any impact on how Octopus behaves.

Would you be open to sending us a HAR file from your browser session using the upload link from yesterday? If so could you also send today’s server log so we have the matching entries from the HAR? The development team has started looking into this however I don’t have an update yet. I will send along this information though and hopefully hear something back from them tonight.

Thanks!

Hi @dan_close,

I uploaded the HAR file and uploaded the new log file as well to that same link.

Thanks again for looking into this.

-Kevin