Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support matching reflected binding names #603

Merged
merged 2 commits into from
Aug 30, 2021
Merged

Support matching reflected binding names #603

merged 2 commits into from
Aug 30, 2021

Conversation

cgillum
Copy link
Member

@cgillum cgillum commented Aug 26, 2021

Context

I ran into an issue when trying to get Durable Functions triggers to work with the isolated worker.

The current rule for extensions is that the attribute name in Worker.Extensions.* must match the attribute name in the corresponding WebJobs.Extensions.*. However, this doesn't work when the WebJobs attribute doesn't end with "InputAttribute" or "OutputAttribute". For example, when I created an attribute named DurableClientAttribute in the worker repo, the function.json that got generated looked like the following:

  {
    "name": "json",
    "type": "DurableClientAttribute",
    "direction": "In",
    "dataType": "String"
  },

The type property value is obviously wrong and resulted in the function app not being able to start.

Fix

I've updated the SDK build task to make my scenario work according to the naming guidelines in WebJobs. I've also lowercased the first latter of the type value so that it matches the documentation (this is slightly vain since types appear to be case-insensitive, but I think it's going to be safer this way in case other tools/systems aren't case-insensitive).

The result was the following:

  {
    "name": "json",
    "type": "durableClient",
    "direction": "In",
    "dataType": "String"
  },

With this change, the function app was able to start and invoke the binding correctly.

@@ -610,7 +610,8 @@ private static string GetBindingType(CustomAttribute attribute)
return attributeType
.Replace("TriggerAttribute", "Trigger")
.Replace("InputAttribute", string.Empty)
.Replace("OutputAttribute", string.Empty);
.Replace("OutputAttribute", string.Empty)
.Replace("Attribute", string.Empty);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider adding a test to FunctionMetadataGeneratorTests for the DurableClientAttribute case ? I do not see any for durable attribute in that today.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking I'll wait until we've added the durable attributes before adding those specific tests. That's going to be a much larger PR though.

@cgillum cgillum merged commit fb20320 into main Aug 30, 2021
@cgillum cgillum deleted the cgillum/sdk-updates branch August 30, 2021 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants