Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.28k stars 424 forks source link

System.Private.CoreLib: Result: Failure Value cannot be null. (Parameter 'value') #2044

Open carct opened 4 years ago

carct commented 4 years ago

System.Private.CoreLib: Result: Failure Exception: Value cannot be null. (Parameter 'value')

above error is thrown in local-dev runtime environment when calling the HttpTrigger with POST and JSON-format payload on a PowerShell AzFunctionApp-v3 NB: error is thrown before any code is executed for validation i left in my run.ps1 just the following lines (commenting all the rest) and error was still thrown:

using namespace System.Net
param($Request, $TriggerMetadata)

azure-functions-core-tools installation: npm i -g azure-functions-core-tools@3 --unsafe-perm true which translated to version 3.0.2534

fix = downgrade to 3.0.2245: npm i -g azure-functions-core-tools@3.0.2245 --unsafe-perm true

configuration files + other environment tools & versions

function.json

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "Request",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "Response"
    }
  ]
}

.vscode/settings.json

{
    "azureFunctions.deploySubpath": ".",
    "azureFunctions.projectLanguage": "PowerShell",
    "azureFunctions.projectRuntime": "~3",
    "azureFunctions.showExplorer": true,
    "azureFunctions.stopFuncTaskPostDebug": false,
    "azureFunctions.validateFuncCoreTools": true,
    "debug.internalConsoleOptions": "openOnSessionStart",
    "debug.allowBreakpointsEverywhere": true,
    "debug.extensionHost.useV3": true,
    "powershell.powerShellDefaultVersion": "~7",
    "terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"
}

host.json

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  },
  "managedDependency": {
    "enabled": true
  },
  "extensions": {
      "http": {
          "routePrefix": ""
      }
  }
}

VSCode 1.46.0 MS PowerShell VSCode Extension v2020.6.0 =====> PowerShell Integrated Console v2020.6.0 <=====

PSVersion                      7.0.2
PSEdition                      Core
carct commented 4 years ago

fix = downgrade to 3.0.2245 scenario:

function loads in runtime, successfully serves request and processes payload, make a change to code, save, function runtime reloads everything, send again a request and same error turns up CTRL+C to close the runtime, rerun with F5 without changing anything everything works, but some other times i need reset (click on Kill Terminal) for both =====> PowerShell Integrated Console v2020.6.0 <===== and Task > Executing task: func start --script-root src < once i do this it seems to work everytime

carct commented 4 years ago

btw, the --watch flag from the func CLI does not influence behavior what-so-ever

anthonychu commented 4 years ago

@AnatoliB @Francisco-Gamino Can you please take a look to see what this problem might be? Thanks.

AnatoliB commented 4 years ago

@carct Do you have any code in the profile.ps1 file in the root of your app? Does the issue repro if you remove or comment out all the code there?

carct commented 4 years ago

@AnatoliB i have a line for loading modules but behavior is consistent with or without that line

AnatoliB commented 4 years ago

@carct I was unable to repro this on a simple app. If possible, could you please share: