Skip to content

[BUG]: unhandled exception in MinimalPermissionsPlugin when no matched operations found #1021

Closed
@waldekmastykarz

Description

@waldekmastykarz

Description

Unhandled exception in MinimalPermissionsPlugin when no matched operations found

Expected behaviour

User-friendly error

Actual behaviour

 fail    An error occurred in a plugin Exception Details: System.Exception: Exception thrown in user event
 ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at DevProxy.Plugins.RequestLogs.MinimalPermissionsPlugin.AfterRecordingStopAsync(Object sender, RecordingArgs e) in /Users/waldek/github/waldekmastykarz/dev-proxy/dev-proxy-plugins/RequestLogs/MinimalPermissionsPlugin.cs:line 103
   at DevProxy.Abstractions.FuncExtensions.InternalInvokeAsync[T](AsyncEventHandler`1 callback, Object sender, T args, ExceptionHandler exceptionFunc) in /Users/waldek/github/waldekmastykarz/dev-proxy/dev-proxy-abstractions/FuncExtensions.cs:line 26

Steps to reproduce

See config file

Dev Proxy Version

v0.25.0

Operating system (environment)

macOS

Shell

zsh

Configuration file

devproxyrc.json:

{
	"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.25.0/rc.schema.json",
	"plugins": [
		{
      "name": "MinimalPermissionsPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
      "configSection": "minimalPermissionsPlugin"
    }
	],
	"urlsToWatch": [
		"https://*.sharepoint.com/*"
	],
  "minimalPermissionsPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.25.0/minimalpermissionsplugin.schema.json",
    "apiSpecsFolderPath": "./.devproxy"
  },
	"logLevel": "information",
	"newVersionNotification": "stable",
	"showSkipMessages": true,
  "record": true
}

sharepoint.yaml

$schema: https://spec.openapis.org/oas/3.0/schema/2021-09-28
openapi: 3.0.4
info:
  title: SharePoint REST API
  description: SharePoint REST API
  version: v1.0
servers:
  - url: https://2czk3g.sharepoint.com
    variables:
      tenant:
        default: contoso
components:
  securitySchemes:
    delegated:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://login.microsoftonline.com/common/v2.0/oauth2/authorize
          tokenUrl: https://login.microsoftonline.com/common/v2.0/oauth2/token
          scopes:
            AllSites.FullControl: AllSites.FullControl
            AllSites.Manage: AllSites.Manage
            AllSites.Read: AllSites.Read
            AllSites.Write: AllSites.Write
            EnterpriseResource.Read: EnterpriseResource.Read
            EnterpriseResource.Write: EnterpriseResource.Write
            MyFiles.Read: MyFiles.Read
            MyFiles.Write: MyFiles.Write
            Project.Read: Project.Read
            Project.Write: Project.Write
            ProjectWebApp.FullControl: ProjectWebApp.FullControl
            ProjectWebAppReporting.Read: ProjectWebAppReporting.Read
            Sites.Search.All: Sites.Search.All
            TaskStatus.Submit: TaskStatus.Submit
            TermStore.Read.All: TermStore.Read.All
            TermStore.ReadWrite.All: TermStore.ReadWrite.All
            User.Read.All: User.Read.All
            User.ReadWrite.All: User.ReadWrite.All
    application:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://login.microsoftonline.com/common/v2.0/oauth2/token
          scopes:
            Sites.FullControl.All: Sites.FullControl.All
            Sites.Manage.All: Sites.Manage.All
            Sites.Read.All: Sites.Read.All
            Sites.ReadWrite.All: Sites.ReadWrite.All
            Sites.Selected: Sites.Selected
            TermStore.Read.All: TermStore.Read.All
            TermStore.ReadWrite.All: TermStore.ReadWrite.All
            User.Read.All: User.Read.All
            User.ReadWrite.All: User.ReadWrite.All
paths:
  /_api/web/webs:
    get:
      security:
        - delegated:
          - AllSites.Read
          - AllSites.Write
          - AllSites.Manage
          - AllSites.FullControl
        - application:
          - Sites.Read.All
          - Sites.Manage.All
          - Sites.ReadWrite.All
          - Sites.FullControl.All
x-ms-generated-by:
  toolName: Dev Proxy
  toolVersion: 0.25.0

Start Dev Proxy

Run:

HTTP_PROXY=http://127.0.0.1:8000 m365 spo web list -u /

Stop recording

Additional Info

No response

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions