Skip to content

UX/DX: improving module cohesion and binding surfaces - #63

Merged
duglin merged 7 commits into
cloudevents:mainfrom
oising:oising/improve-ux-dx-1
Nov 29, 2026
Merged

duglin merged 7 commits into
cloudevents:mainfrom
oising:oising/improve-ux-dx-1

Conversation

@oising

@oising oising commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

PR #63: Improvements and fixes

Planned in #61

  • HTTP pipelines: Bind Headers and Body/Content by property name, including Invoke-WebRequest dictionaries. Support HTTP-message round trips.
  • HTTP output: Retain the Headers/Body shape and add the CloudEvents.HttpMessage type name.
  • Event creation: Bind event properties from pipeline objects and generate missing IDs and timestamps per record.
  • Data setters: Bind data and metadata from wrapper properties. Prevent a directly piped event’s own data from being mistaken for replacement data.
  • Data readers: Accept wrapper objects containing a CloudEvent property.
  • Command metadata: Add output types, InputObject/Event aliases and consistent CloudEvent input validation.
  • 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.

Closes: #61

Type of change

Please mark options that are relevant:

  • 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

Copilot AI balanced review requested due to automatic review settings November 20, 2026 14:50
@oising
oising marked this pull request as draft November 20, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved defects break positional API compatibility and lowercase-header handling, mishandle pipeline defaults, and leave events partially modified when schema validation fails.

6 open issues
What changed in this PR

This PR addresses #61 by improving pipeline interoperability across the CloudEvents PowerShell SDK’s creation, data, and HTTP conversion commands.

Changes:

  • Adds property-name binding, common aliases, output metadata, and default event IDs and timestamps.
  • Improves HTTP message round-tripping and Invoke-WebRequest response binding.
  • Adds regression tests and pipeline examples, and bumps the module version to 0.4.0.
File Description
test/​unit/​Set-CloudEventXmlData.Tests.ps1 Tests property-bound XML data and schema.
test/​unit/​Set-CloudEventJsonData.Tests.ps1 Tests property binding and guards against implicit data replacement.
test/​unit/​Set-CloudEventData.Tests.ps1 Tests property-bound data and metadata.
test/​unit/​Read-CloudEventXmlData.Tests.ps1 Tests wrapper input and XML conversion modes.
test/​unit/​Read-CloudEventJsonData.Tests.ps1 Tests JSON reading from wrapper objects.
test/​unit/​Read-CloudEventData.Tests.ps1 Tests raw data reading from wrapper objects.
test/​unit/​New-CloudEvent.Tests.ps1 Tests pipeline creation, defaults, and explicit metadata.
test/​unit/​ConvertTo-HttpMessage.Tests.ps1 Checks common CloudEvent parameter aliases.
test/​unit/​ConvertFrom-HttpMessage.Tests.ps1 Tests HTTP round-tripping and response-shaped input.
src/​CloudEventsPowerShell/​CloudEvents.Sdk.psm1 Updates binding, defaults, schema handling, HTTP headers, and command help.
src/​CloudEventsPowerShell/​CloudEvents.Sdk.psd1 Bumps the module version to 0.4.0.
README.md Adds pipeline recipes and updates displayed versions.
CHANGELOG.md Records binding improvements, guards, and documentation updates.

Review effort: Balanced

@oising
oising marked this pull request as ready for review November 20, 2026 14:59
@oising
oising marked this pull request as draft November 20, 2026 15:37
@oising

oising commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

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.

@oising
oising requested a balanced review from Copilot November 20, 2026 18:41
@oising
oising marked this pull request as ready for review November 20, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Property binding rejects null-body messages, and a valid HTTP header named Keys prevents binary CloudEvents from being recognized.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Allow null bodies for binary CloudEvents

src/​CloudEventsPowerShell/​CloudEvents.Sdk.psm1:985

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.

Medium severity Avoid Keys header shadowing the dictionary property

src/​CloudEventsPowerShell/​CloudEvents.Sdk.psm1:1046

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.

6 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Null-valued pipeline properties cause timestamp binding failures and unintended content-type replacement, leaving two correctness issues unresolved.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Accept null pipeline timestamps when cloning events

src/​CloudEventsPowerShell/​CloudEvents.Sdk.psm1:88

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.

Medium severity Use the bound content type to reject null wrapper values

src/​CloudEventsPowerShell/​CloudEvents.Sdk.psm1:248

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.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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.

2 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the PowerShell pipeline improvements.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed to weigh a documentation nit about PowerShell splatting that was omitted from the published review.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@oising

oising commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@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).

oising and others added 6 commits November 20, 2026 15:27
Signed-off-by: Oisin Grehan <oisin.grehan@ionodes.com>
See: PowerShell/PowerShell#20137

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Oisin Grehan <oisin.grehan@ionodes.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Oisin Grehan <oisin.grehan@ionodes.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Oisin Grehan <oisin.grehan@ionodes.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Oisin Grehan <oisin.grehan@ionodes.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Oisin Grehan <oisin.grehan@ionodes.com>
@oising
oising force-pushed the oising/improve-ux-dx-1 branch from 5028eb4 to 724c8e7 Compare November 20, 2026 20:27
Signed-off-by: Oisin Grehan <oisin.grehan@ionodes.com>
@duglin

duglin commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

@oising thanks!!!

@duglin
duglin merged commit f409509 into cloudevents:main Nov 29, 2026
7 checks passed
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.

Enhance ux/dx

3 participants