feat(stream): add streaming CBOR decoder API - #20
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new push-based, event-driven streaming CBOR decoder API (headers + implementation), along with documentation, unit tests, a dedicated test runner, and a release workflow tweak.
Changes:
- Introduces
cbor_stream_*public API and a state-machine based streaming decoder implementation. - Adds comprehensive CppUTest coverage for streaming decoding behavior (scalars, strings, containers, tags, errors, reset).
- Updates release workflow to use
$GITHUB_ENV+gh release create.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
src/stream.c |
Implements the streaming decoder state machine and public cbor_stream_* functions. |
include/cbor/stream.h |
Defines the streaming decoder public API, events, callback contract, and decoder state struct. |
include/cbor/cbor.h |
Exposes the streaming API via the umbrella public header. |
include/cbor/base.h |
Extends cbor_error_t with streaming-oriented error codes. |
README.md |
Documents streaming decoder usage and event semantics with an example and API summary. |
tests/src/stream_test.cpp |
Adds unit tests for streaming decoder behavior and error handling. |
tests/runners/stream.mk |
Adds a dedicated test runner configuration for the streaming decoder. |
.github/workflows/release.yml |
Switches version propagation to $GITHUB_ENV and creates releases via GitHub CLI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
.github/workflows/release.yml:31
gh release createrequires the workflow token to have write access to repository contents. Since this workflow doesn’t set explicitpermissions, it may run with the default read-onlyGITHUB_TOKENpermissions and fail to create the release. Consider addingpermissions: contents: writeat the workflow or job level.
name: release
on:
push:
tags:
- '*'
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Compile
run: make
- name: Install test framework
run: make -C tests install
- name: Unit Test
run: make -C tests
- name: Create Release
run: |
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
.github/workflows/release.yml:31
gh release createrequirescontents: writepermissions for the workflow token in repos/orgs with restricted default permissions. Add an explicitpermissions: contents: write(either at workflow or job level) to avoid release creation failing with a 403 whenGITHUB_TOKENis read-only.
- name: Create Release
run: |
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| TEST(StreamError, ShouldStickyError_WhenSubsequentFeedAfterError) | ||
| { | ||
| uint8_t bad[] = { 0xff }; | ||
| uint8_t good[] = { 0x01 }; | ||
|
|
||
| LONGS_EQUAL(CBOR_ILLEGAL, cbor_stream_feed(&decoder, bad, sizeof(bad))); | ||
| LONGS_EQUAL(CBOR_ILLEGAL, cbor_stream_feed(&decoder, good, sizeof(good))); | ||
| LONGS_EQUAL(0, rec.count); /* no extra events */ |
There was a problem hiding this comment.
Test name has a grammatical typo: "ShouldStickyError_WhenSubsequentFeedAfterError" reads awkwardly and is inconsistent with other test names. Consider renaming to something like "ShouldBeStickyError_WhenSubsequentFeedAfterError" (or similar) to improve readability/searchability.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|



This pull request introduces a new streaming CBOR decoder to the codebase, allowing incremental, push-based decoding of CBOR data. It includes the implementation, documentation, public API exposure, and test runner setup for the streaming decoder. Additionally, there are minor improvements to the release workflow and error handling.
Streaming Decoder Implementation and Documentation:
cbor/stream.hheader, defining the streaming decoder API, event types, callback mechanism, and decoder state structures. This enables incremental, event-driven decoding of CBOR data.README.mdwith a comprehensive section describing the streaming decoder usage, event callbacks, string and container handling, and API summary.Public API and Error Handling:
cbor/stream.hin the maincbor.hheader to expose the streaming decoder API to users.cbor_error_tenum withCBOR_NEED_MOREandCBOR_ABORTEDerror codes to support streaming decoder error reporting.Testing:
tests/runners/stream.mkfor the streaming decoder, specifying source files and test configuration.Release Workflow:
.github/workflows/release.ymlto use environment variables and the GitHub CLI for release creation, improving compatibility with recent GitHub Actions changes.