Skip to content

Commit

Permalink
using a different error message in case extension bundle is configure…
Browse files Browse the repository at this point in the history
…d. (Azure#5467)
  • Loading branch information
soninaren committed Mar 24, 2020
1 parent 92e4aa6 commit bf96005
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/WebJobs.Script/Description/FunctionDescriptorProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Script.Binding;
using Microsoft.Azure.WebJobs.Script.Configuration;
using Microsoft.Azure.WebJobs.Script.Extensibility;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -85,8 +86,8 @@ public void VerifyResolvedBindings(FunctionMetadata functionMetadata, IEnumerabl
if (unresolvedBindings.Any())
{
string allUnresolvedBindings = string.Join(", ", unresolvedBindings);
throw new FunctionConfigurationException($"The binding type(s) '{allUnresolvedBindings}' are not registered. " +
$"Please ensure the type is correct and the binding extension is installed.");
string errorMessage = CreateBindingError(allUnresolvedBindings);
throw new FunctionConfigurationException(errorMessage);
}
}

Expand Down Expand Up @@ -135,8 +136,8 @@ protected virtual ParameterDescriptor CreateTriggerParameter(BindingMetadata tri
}
else
{
throw new FunctionConfigurationException($"The binding type '{triggerMetadata.Type}' is not registered. " +
$"Please ensure the type is correct and the binding extension is installed.");
string errorMessage = CreateBindingError(triggerMetadata.Type);
throw new FunctionConfigurationException(errorMessage);
}

return triggerParameter;
Expand Down Expand Up @@ -243,5 +244,12 @@ protected ParameterDescriptor ParseManualTrigger(BindingMetadata trigger, Type t

return new ParameterDescriptor(trigger.Name, triggerParameterType);
}

private string CreateBindingError(string unresolvedBindings)
{
return (Host.ExtensionBundleManager?.IsExtensionBundleConfigured() ?? false)
? $"The binding type(s) '{unresolvedBindings}' were not found in the configured extension bundle. Please ensure the type is correct and the correct version of extension bundle is configured"
: $"The binding type(s) '{unresolvedBindings}' are not registered. Please ensure the type is correct and the binding extension is installed.";
}
}
}
5 changes: 5 additions & 0 deletions src/WebJobs.Script/Host/ScriptHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Microsoft.Azure.WebJobs.Script.Diagnostics.Extensions;
using Microsoft.Azure.WebJobs.Script.Eventing;
using Microsoft.Azure.WebJobs.Script.Extensibility;
using Microsoft.Azure.WebJobs.Script.ExtensionBundle;
using Microsoft.Azure.WebJobs.Script.Workers;
using Microsoft.Azure.WebJobs.Script.Workers.Http;
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
Expand Down Expand Up @@ -105,6 +106,7 @@ public ScriptHost(IOptions<JobHostOptions> options,
IHostIdProvider hostIdProvider,
IHttpRoutesManager httpRoutesManager,
IApplicationLifetime applicationLifetime,
IExtensionBundleManager extensionBundleManager,
ScriptSettingsManager settingsManager = null)
: base(options, jobHostContextFactory)
{
Expand All @@ -131,6 +133,7 @@ public ScriptHost(IOptions<JobHostOptions> options,
EventManager = eventManager;
_functionDispatcher = functionDispatcherFactory.GetFunctionDispatcher();
_settingsManager = settingsManager ?? ScriptSettingsManager.Instance;
ExtensionBundleManager = extensionBundleManager;

_metricsLogger = metricsLogger;

Expand Down Expand Up @@ -165,6 +168,8 @@ public ScriptHost(IOptions<JobHostOptions> options,

public IScriptEventManager EventManager { get; }

internal IExtensionBundleManager ExtensionBundleManager { get; }

public ILogger Logger { get; internal set; }

public ScriptJobHostOptions ScriptOptions { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task VerifyResolvedBindings_WithNoBindingMatch_ThrowsExpectedExcept
var (created, descriptor) = await _provider.TryCreate(functionMetadata);
});

Assert.Contains("unknownbinding", ex.Message);
Assert.Contains("The binding type(s) 'unknownbinding' are not registered", ex.Message);
}

[Fact]
Expand Down

0 comments on commit bf96005

Please sign in to comment.