Skip to content

Commit

Permalink
Merge branch 'v4.x' into ej/httpStream
Browse files Browse the repository at this point in the history
  • Loading branch information
ejizba committed Jan 31, 2024
2 parents 8006b89 + b4f1389 commit 242277a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/functions",
"version": "4.1.0",
"version": "4.2.0",
"description": "Microsoft Azure Functions NodeJS Framework",
"keywords": [
"azure",
Expand Down
11 changes: 10 additions & 1 deletion src/InvocationModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { fromRpcTypedData } from './converters/fromRpcTypedData';
import { toCamelCaseValue } from './converters/toCamelCase';
import { toRpcHttp } from './converters/toRpcHttp';
import { toRpcTypedData } from './converters/toRpcTypedData';
import { AzFuncSystemError } from './errors';
import { waitForProxyRequest } from './http/httpProxy';
import { HttpRequest } from './http/HttpRequest';
import { InvocationContext } from './InvocationContext';
Expand Down Expand Up @@ -64,7 +65,15 @@ export class InvocationModel implements coreTypes.InvocationModel {
for (const binding of req.inputData) {
const bindingName = nonNullProp(binding, 'name');

const bindingType = nonNullProp(this.#bindings, bindingName).type;
const rpcBinding = this.#bindings[bindingName];
if (!rpcBinding) {
throw new AzFuncSystemError(
`Failed to find binding "${bindingName}" in bindings "${Object.keys(this.#bindings).join(
', '
)}".`
);
}
const bindingType = rpcBinding.type;

let input: unknown;
if (isHttpTrigger(bindingType) && isHttpStreamEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

export const version = '4.1.0';
export const version = '4.2.0';

export const returnBindingKey = '$return';
31 changes: 31 additions & 0 deletions test/InvocationModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,36 @@ describe('InvocationModel', () => {
const response = await model.getResponse(context, undefined);
expect(response).to.deep.equal({ invocationId: 'testInvocId', outputData: [], returnValue: undefined });
});

// https://github.com/Azure/azure-functions-nodejs-library/issues/210
it('Missing binding', async () => {
const model = new InvocationModel({
invocationId: 'testInvocId',
metadata: {
name: 'testFuncName',
bindings: {
httpTrigger1: {
type: 'httpTrigger',
direction: 'in',
},
$return: {
type: 'http',
direction: 'out',
},
},
},
request: {
inputData: [
{
name: 'httpTriggerMissing',
},
],
},
log: testLog,
});
await expect(model.getArguments()).to.be.rejectedWith(
'Failed to find binding "httpTriggerMissing" in bindings "httpTrigger1, $return".'
);
});
});
});

0 comments on commit 242277a

Please sign in to comment.