Skip to content

Phase 4: SDK gaps for CLI usage#28

Open
alxgsv wants to merge 3 commits intocodex/phase3-sdk-enhancementsfrom
codex/phase4-sdk-gaps
Open

Phase 4: SDK gaps for CLI usage#28
alxgsv wants to merge 3 commits intocodex/phase3-sdk-enhancementsfrom
codex/phase4-sdk-gaps

Conversation

@alxgsv
Copy link
Copy Markdown
Contributor

@alxgsv alxgsv commented Mar 14, 2026

  • add Upload API metadata support and propagate it through unified upload helpers
  • add file include params, conversion save_in_group support, and conversion path builder helpers
  • change webhook delete to operate on webhook IDs and update docs/changelog/examples
  • add unit coverage for codec encoding, file info/list params, conversion helpers, upload metadata, and webhook deletion

Summary by CodeRabbit

Release Notes

  • New Features

    • Added metadata support for file uploads
    • Optional include parameters now available for file operations
    • Conversion path utilities added for document and video processing
    • SaveInGroup parameter added for conversion operations
  • API Changes

    • file.Info() method signature updated to accept optional parameters
    • webhook.Delete() method updated to use webhook ID instead of URL

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 14, 2026

Walkthrough

This pull request introduces breaking API changes to file and webhook services, adds support for optional include parameters and metadata in uploads, implements path-building utilities for conversions, and enhances codec handling for map-based form fields. Multiple service signatures are updated, new optional parameter types are added, and comprehensive test coverage is provided.

Changes

Cohort / File(s) Summary
File Service Info Method
file/service.go, file/file.go, file/service_test.go, test/file.go
Updated Info() method signature to accept *InfoParams for optional include parameters. Added InfoParams struct with Include field and EncodeReq method. Tests validate include parameter encoding and nil handling.
File List Parameters
file/list.go
Added optional Include field to ListParams with form tag for query parameter encoding.
Conversion Enhancements
conversion/conversion.go, conversion/conversion_test.go, conversion/path.go, conversion/path_test.go
Added SaveInGroup field to conversion Params. Introduced path-building utilities: DocumentPathOptions/BuildDocumentPath and VideoPathOptions/BuildVideoPath for constructing conversion paths with optional parameters. Comprehensive tests verify path construction with various parameter combinations.
Webhook Service Delete by ID
webhook/service.go, webhook/webhook.go, webhook/service_test.go, test/webhook.go
Changed Delete() method signature from Delete(targetURL string) to Delete(id int64) for ID-based deletion. Updated implementation and removed unused deleteParams struct. Added test validating DELETE request to webhook ID endpoint.
Upload Metadata Support
upload/direct.go, upload/fromurl.go, upload/multipart.go, upload/upload.go, upload/upload_test.go
Added Metadata field (map[string]string) to FileParams, FromURLParams, MultipartParams, and UploadParams. Tests validate metadata is properly included in direct and multipart upload payloads.
Codec Map Handling
internal/codec/codec.go, internal/codec/codec_test.go
Enhanced EncodeReqQuery and writeFormField to support map[string]string fields in form tags, enabling nested key-value encoding. Updated tests to cover metadata handling scenarios and renamed test functions to exported convention.
Upload API Response Handling
ucare/uploadapi.go, ucare/uploadapi_test.go
Changed JSON unmarshaling in handleResponse to require pointer types. Added test validating error handling for non-pointer results.
Documentation Updates
CHANGELOG.md, README.md, ucare/doc.go
Updated code examples and documentation to reflect new method signatures and parameter additions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Phase 4: SDK gaps for CLI usage' directly aligns with the PR objectives, which describe closing phase 4 SDK CLI gaps and adding multiple capabilities for CLI usage.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/phase4-sdk-gaps
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can generate walkthrough in a markdown collapsible section to save space.

Enable the reviews.collapse_walkthrough setting to generate walkthrough in a markdown collapsible section.

@alxgsv
Copy link
Copy Markdown
Contributor Author

alxgsv commented Mar 14, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 14, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
conversion/path_test.go (1)

30-35: Consider adding edge case tests for video paths.

The basic test validates a minimal path with Format: "mp4". Consider adding tests for:

  • Empty Format to document expected behavior
  • Partial cut parameters (CutStart only or CutLength only)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@conversion/path_test.go` around lines 30 - 35, Add edge-case unit tests for
BuildVideoPath using the VideoPathOptions struct: add a test that sets Format to
an empty string to assert the expected output when format is omitted, and two
tests for partial cut parameters—one with CutStart set and CutLength
zero/omitted, and one with CutLength set and CutStart zero/omitted—to assert the
path produced when only one cut param is provided; locate and extend
TestBuildVideoPath_Basic (or create new tests named
TestBuildVideoPath_EmptyFormat and
TestBuildVideoPath_PartialCutStart/PartialCutLength) to validate these behaviors
against the canonical path format returned by BuildVideoPath.
conversion/path.go (2)

56-58: Consider defaulting or validating Format for video paths.

Unlike BuildDocumentPath which defaults Format to "pdf", BuildVideoPath produces a path with an empty format segment (uuid/video/-/format//) when Format is empty. This could result in invalid conversion paths.

🛠️ Option: Add a default format or document the requirement

Either default to a common format:

 func BuildVideoPath(opts VideoPathOptions) string {
+	format := opts.Format
+	if format == "" {
+		format = "mp4"
+	}
+
 	var b strings.Builder
-	fmt.Fprintf(&b, "%s/video/-/format/%s/", opts.UUID, opts.Format)
+	fmt.Fprintf(&b, "%s/video/-/format/%s/", opts.UUID, format)

Or document that Format is required via the struct comment on line 40.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@conversion/path.go` around lines 56 - 58, BuildVideoPath currently emits an
empty format segment when VideoPathOptions.Format is blank; update
BuildVideoPath to validate/default the format (similar to BuildDocumentPath) by
checking if opts.Format == "" and setting a sensible default like "mp4" before
formatting the path, or alternatively document that VideoPathOptions.Format is
required in the VideoPathOptions struct comment so callers must supply it;
reference the BuildVideoPath function and VideoPathOptions type when making the
change.

71-73: Partial cut parameters produce no output — document or handle.

If only CutStart or only CutLength is provided, the cut segment is silently omitted. This is likely intentional (both are required for a valid cut), but documenting this behavior in the struct field comments would help users avoid mistakes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@conversion/path.go` around lines 71 - 73, The code silently omits a cut when
only one of opts.CutStart or opts.CutLength is provided; either document that
both fields are required on the options struct or add validation in the
path-building code to handle partial input. Locate the options type that defines
CutStart and CutLength and add a clear comment stating “both CutStart and
CutLength must be set to produce a cut”; alternatively (or additionally) modify
the path-construction logic that checks opts.CutStart/opts.CutLength to detect
when only one is set and return an error (or log and skip) rather than silently
omitting the cut, updating any callers to handle the validation result.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@conversion/path_test.go`:
- Around line 30-35: Add edge-case unit tests for BuildVideoPath using the
VideoPathOptions struct: add a test that sets Format to an empty string to
assert the expected output when format is omitted, and two tests for partial cut
parameters—one with CutStart set and CutLength zero/omitted, and one with
CutLength set and CutStart zero/omitted—to assert the path produced when only
one cut param is provided; locate and extend TestBuildVideoPath_Basic (or create
new tests named TestBuildVideoPath_EmptyFormat and
TestBuildVideoPath_PartialCutStart/PartialCutLength) to validate these behaviors
against the canonical path format returned by BuildVideoPath.

In `@conversion/path.go`:
- Around line 56-58: BuildVideoPath currently emits an empty format segment when
VideoPathOptions.Format is blank; update BuildVideoPath to validate/default the
format (similar to BuildDocumentPath) by checking if opts.Format == "" and
setting a sensible default like "mp4" before formatting the path, or
alternatively document that VideoPathOptions.Format is required in the
VideoPathOptions struct comment so callers must supply it; reference the
BuildVideoPath function and VideoPathOptions type when making the change.
- Around line 71-73: The code silently omits a cut when only one of
opts.CutStart or opts.CutLength is provided; either document that both fields
are required on the options struct or add validation in the path-building code
to handle partial input. Locate the options type that defines CutStart and
CutLength and add a clear comment stating “both CutStart and CutLength must be
set to produce a cut”; alternatively (or additionally) modify the
path-construction logic that checks opts.CutStart/opts.CutLength to detect when
only one is set and return an error (or log and skip) rather than silently
omitting the cut, updating any callers to handle the validation result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: af485dbd-c2d8-4905-87f4-4fc73b5e730b

📥 Commits

Reviewing files that changed from the base of the PR and between d6b5cc1 and 4ab8284.

📒 Files selected for processing (25)
  • CHANGELOG.md
  • README.md
  • conversion/conversion.go
  • conversion/conversion_test.go
  • conversion/path.go
  • conversion/path_test.go
  • file/file.go
  • file/list.go
  • file/service.go
  • file/service_test.go
  • internal/codec/codec.go
  • internal/codec/codec_test.go
  • test/file.go
  • test/webhook.go
  • ucare/doc.go
  • ucare/uploadapi.go
  • ucare/uploadapi_test.go
  • upload/direct.go
  • upload/fromurl.go
  • upload/multipart.go
  • upload/upload.go
  • upload/upload_test.go
  • webhook/service.go
  • webhook/service_test.go
  • webhook/webhook.go

@alxgsv alxgsv changed the title feat: close phase 4 sdk cli gaps Phase 4: SDK gaps for CLI usage Mar 16, 2026
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.

1 participant