Skip to content

Type convertion issue #35

@shrexster42

Description

@shrexster42

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I have created a FunctionHandler as below

public class SendToDynamicsHandler extends FunctionInvoker<VendorIdentifier, BRParty> {

    @FunctionName("processVendor")
    public HttpResponseMessage execute(
            @HttpTrigger(name = "request", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<VendorIdentifier>> request,
            ExecutionContext context) {
        VendorIdentifier vendorIdentifier = request.getBody().get();
        context.getLogger().info("Vendor Id" + vendorIdentifier.getPartyId());
        return request
                .createResponseBuilder(HttpStatus.OK)
                .body(handleRequest(vendorIdentifier, context))
                .header("Content-Type", "application/json")
                .build();
    }
}

and the VendorIdentifier POJO as

public class VendorIdentifier {
	
	@JsonProperty("party_id")
	private String partyId;
	
	@JsonProperty("status")
	private String status;

	public String getPartyId() {
		return partyId;
	}

	public void setPartyId(String partyId) {
		this.partyId = partyId;
	}

        public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
}

The payload sent to the function as

{
    "party_id": "VEN1234",
    "status": "APPROVED"
}

I see a type conversion issue when the function receives the parameter HttpRequestMessage<Optional<VendorIdentifier>> request. The partyId property is not populated in the VendorIdentifier and value is null. The status maps correctly as there is no difference between payload and the property in the pojo.

I have marked partyId using the jackson @JsonProperty annotation to handle mapping of the payload containing party_id field into partyId property, but it does not happen.

Any log messages given by the failure

None

Expected/desired behavior

Jackson annotations should be enforced and POJO mapped properly during type conversion

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Windows 10.

Versions

Azure Functions CLI installed locally - v4.0.4544

Mention any other details that might be useful

Project built using maven as in the sample.


Thanks! We'll be in touch soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions