You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UX/DX: improving module cohesion and binding surfaces - #63
Content-type fix: Construct and assign a ContentType only when supplied.
Docs and tests: Add pipeline examples, help metadata and regression tests. Bump the module version to 0.4.0.
Additional fixes and refinements
Add DataSchema support to the XML setter; the issue requested property binding for it, but the parameter did not yet exist.
Validate schemas before mutating data, preserving the original event on validation failure.
Handle per-record binding edge cases, including omitted metadata after a previous record supplied it, null pipeline timestamps, and delay-bound Time/DataSchema values.
Reject null wrapper content types instead of silently replacing them with application/octet-stream.
Normalize HTTP header lookup case, handle a header named Keys, and accept null bodies for binary events.
Emit HTTP Content-Type header values as strings.
Preserve the existing positional XML setter API while adding DataSchema.
Planned but unchanged or deferred
JSON read and write depth defaults were already both 3; no change was needed.
XML ConvertMode was reviewed and tested but remains mandatory. Converting the XML attributes Boolean to a switch and defaulting ConvertMode remain deferred to a future major version.
The README mentions splatting into Invoke-WebRequest, but its example passes Headers and Body individually rather than demonstrating splatting.
Validation
The latest local run passed 88 unit and 5 integration tests.
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to
not work as expected)
This change requires a documentation update
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. If applicable, please also list any relevant
details for your test configuration.
Added new unit tests.
Checklist:
My code follows the contribution guidelines
of this project
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation
I have added tests that prove my fix is effective or that my feature works
New and existing unit tests pass locally with my changes
Any dependent changes have been merged and published in downstream modules
Converting to draft as somehow copilot has picked up on a long standing binding engine bug that I was not aware of, or have long forgotten ( PowerShell/PowerShell#20137 ) -- just putting some extra guards in place to ensure the behaviour is correct.
The new property binding rejects messages whose Body (or aliased Content) is $null, because ValidateNotNull fails before processing. This prevents piping bodyless binary CloudEvents, even though named calls can omit -Body. Allow null for this optional parameter and add a regression test for a null-body message.
Avoid Keys header shadowing the dictionary property
A valid HTTP header named Keys shadows the dictionary's Keys property in PowerShell. With that header present, this condition checks the header value instead of the dictionary keys, so an otherwise valid binary CloudEvent with ce-specversion: 1.0 returns no event. Use ContainsKey() on the normalized dictionary to avoid the member-name collision.
An event without a time attribute cannot use the new event-to-event pipeline binding: its Time property is null, and binding that property to [DateTime] fails with “Cannot convert null to type System.DateTime” before PROCESS runs. The same failure is reproducible with [pscustomobject]@{ Type = 'test'; Source = 'urn:test'; Time = $null } | New-CloudEvent. Please accept nullable pipeline timestamps and treat null as omitted when generating the per-event default, with a regression test for cloning a timestamp-less event.
Use the bound content type to reject null wrapper values
With a wrapper whose DataContentType property is $null, this reads the raw value instead of the bound [string], causing New-Object to select the parameterless constructor and overwrite the event's content type with application/octet-stream. Use the bound $DataContentType value so null is rejected consistently, and add a null-property regression test.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active findings identify silent content-type overwrites for null wrapper values and premature rejection of delay-bound DataSchema arguments before pipeline records are processed.
@duglin This LGTM now. I've added information above about what I tackled in the linked issue as well as new fixes/issues that came up along the way. Unit and regression tests added for everything.
update: rebased and force pushed with sign-off (dco).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PR #63: Improvements and fixes
Planned in #61
HeadersandBody/Contentby property name, includingInvoke-WebRequestdictionaries. Support HTTP-message round trips.Headers/Bodyshape and add theCloudEvents.HttpMessagetype name.CloudEventproperty.InputObject/Eventaliases and consistent CloudEvent input validation.ContentTypeonly when supplied.0.4.0.Additional fixes and refinements
DataSchemasupport to the XML setter; the issue requested property binding for it, but the parameter did not yet exist.Time/DataSchemavalues.application/octet-stream.Keys, and accept null bodies for binary events.Content-Typeheader values as strings.DataSchema.Planned but unchanged or deferred
3; no change was needed.ConvertModewas reviewed and tested but remains mandatory. Converting the XML attributes Boolean to a switch and defaultingConvertModeremain deferred to a future major version.Invoke-WebRequest, but its example passesHeadersandBodyindividually rather than demonstrating splatting.Validation
The latest local run passed 88 unit and 5 integration tests.
Closes: #61
Type of change
Please mark options that are relevant:
not work as expected)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. If applicable, please also list any relevant
details for your test configuration.
Checklist:
guidelines
of this project