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

Message properties that are optional need to be nil-able #93

Merged
merged 11 commits into from
Dec 7, 2021

Conversation

richardpark-msft
Copy link
Member

Some fields that are optional in AMQP were typed as just plain 'string', which meant you couldn't pass an empty string.

This PR changes those fields to now be pointers to string instead. This is an absolutely breaking change for any callers, and could use a bit more testing (I just ran it through the current tests).

@richardpark-msft
Copy link
Member Author

@serbrech, adding you here in case you have any feedback about this.

This would definitely be a breaking API change but we've had a few of those. From my reading (and talking with @jhendrixMSFT I believe he agrees) properties that are of string type but optional need to allow for a "not specified at all" or "empty string" distinction that we can't represent today in our message.

@jhendrixMSFT
Copy link
Member

Per http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#doc-idp115568, all non-mandatory fields can have the null value. Therefore, we should make all non-mandatory fields pointer-to-type.

@richardpark-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@serbrech
Copy link
Member

serbrech commented Dec 2, 2021

pretty confident that we have never used any of these properties, and it's the right thing to do anyways.
thanks for the head's up

@richardpark-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

(got one test failing, not sure if it's related to my change. Changing the pipeline YAML to output the actual test output)

@richardpark-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

I had a flaky test failure with the multi-part message (seems unrelated to my change for fields since those are basically "field is nil or not".

To diagnose this I added a step to dump the output to stdout, and now the tests are passing consistently.

message.go Outdated Show resolved Hide resolved
@jhendrixMSFT
Copy link
Member

Also, could you check to see if other types need this same fix-up? You can roll them into this PR or separate ones.

…erties in here at all as per the spec, so each one should be nilable.

I also added in some type aliases to make it simpler to match the spec to the individual types, at least for message properties.
@richardpark-msft
Copy link
Member Author

Also, could you check to see if other types need this same fix-up? You can roll them into this PR or separate ones.

Okay, I've done another update (still just focusing on message properties, but those are the commonly used ones). This time I created type aliases so the name of the type matches more with the actual type in AMQP. They're all pretty simple.

I also made every optional property actually be optional by making them pointers.

@jhendrixMSFT , can you take another look?

@richardpark-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

Also, filed #114 to look at any other properties to see which ones could use the aliased types.

@richardpark-msft
Copy link
Member Author

Pushed another change to make sure that the marshaller gets exercised with nil properties (also a fix)

@richardpark-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft richardpark-msft merged commit 01b4c64 into Azure:master Dec 7, 2021
@richardpark-msft richardpark-msft deleted the amqp-session-id branch December 7, 2021 19:06
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