bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Removing bicepconfig causes VSCode with bicep registry module to throw errors

Open miqm opened this issue 2 years ago • 5 comments

Bicep version 0.9.1

Describe the bug

  Message: Internal Error - System.ArgumentException: The specified line number is not valid.
   at Bicep.Core.Text.TextCoordinateConverter.GetOffset(IReadOnlyList`1 lineStarts, Int32 line, Int32 character) in C:\__w\1\s\bicep\src\Bicep.Core\Text\TextCoordinateConverter.cs:line 71
   at Bicep.LanguageServer.Utils.PositionHelper.GetOffset(ImmutableArray`1 lineStarts, Position position) in C:\__w\1\s\bicep\src\Bicep.LangServer\Utils\PositionHelper.cs:line 20
   at Bicep.LanguageServer.Handlers.BicepCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in C:\__w\1\s\bicep\src\Bicep.LangServer\Handlers\BicepCodeActionHandler.cs:line 66
   at OmniSharp.Extensions.JsonRpc.JsonRpcServerServiceCollectionExtensions.RequestHandlerDecorator`2.Handle(T request, CancellationToken cancellationToken)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()

To Reproduce

  1. Create bicepconfig.json with br alias to registry
  2. use that registry in bicep file (module mod 'br:alias/module:version' = {})
  3. remove bicepconfig.json
  4. try to edit module path

Additional context Add any other context about the problem here.

miqm avatar Sep 01 '22 13:09 miqm

This error occurred on MacOS. I tried to reproduce it on Windows and I couldn't :/

miqm avatar Sep 02 '22 19:09 miqm

Also, after looking into code it doesn't seem to be a bug in Bicep. probably we did receive some odd values from VSCode. Perhaps we should wrap Handlers with try-catch and always gracefully end handling events?

miqm avatar Sep 02 '22 19:09 miqm

@ucheNkadiCode / @StephenWeatherford - can you take a look at this?

alex-frankel avatar Sep 14 '22 19:09 alex-frankel

My Mac's at home. I'll try to repro later with these files:

{
  "moduleAliases": {
    "ts": {},
    "br": {
      "me": {
        "registry": "mcr.microsoft.com",
        "modulePath": "bicep"
      }
    }
  }
}
module m1 'br/me:samples/hello-world:1.0.2' = {
  name: 'm1'
  params: {
    name: 'me myself'
  }
}

output greeting string = m1.outputs.greeting

StephenWeatherford avatar Sep 14 '22 20:09 StephenWeatherford

@miqm I couldn't repro this. Is there something I'm doing wrong? Thanks.

https://user-images.githubusercontent.com/6913354/191838658-952644f9-444b-4cb0-a738-d630759b7041.mov

StephenWeatherford avatar Sep 22 '22 19:09 StephenWeatherford

Duplicate #1931

anthony-c-martin avatar Oct 05 '22 19:10 anthony-c-martin