Skip to content

Add coded errors, JSON warnings, and contract tests#287

Merged
AndreyVMarkelov merged 1 commit into
masterfrom
json-coded-errors-warnings
Jun 25, 2026
Merged

Add coded errors, JSON warnings, and contract tests#287
AndreyVMarkelov merged 1 commit into
masterfrom
json-coded-errors-warnings

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace fragile string-matching in jsonErrorCode with typed codedError errors that carry their error code from the point of creation
  • Add invalidArgumentsError(), invalidArgumentsErrorf(), pathConflictErrorf(), unsupportedOutputFormatErrorf() factory helpers used across all commands
  • Add JSON warnings infrastructure: renderJSONOperationOutputWithWarnings() and warning code constants (deprecated_command, skipped_symlink)
  • Emit deprecated_command warning when using the legacy share list link command in JSON mode
  • Emit skipped_symlink warning during put --recursive in JSON mode when symlinks are encountered
  • Add contract tests: command audit (verifies the structured output surface), operation output shape, and unsupported command JSON error envelope

Test plan

  • go test ./cmd/... passes — includes new contract tests and coded error assertions
  • golangci-lint run ./... passes
  • TestStructuredOutputCommandAudit fails if a command gains/loses enableStructuredOutput without updating the list
  • TestJSONErrorCodeUsesCodedErrors verifies all coded error types map to correct codes
  • TestJSONErrorCodeDoesNotClassifyPlainValidationStrings ensures old string patterns no longer match
  • TestPutJSONRecursiveWarnsForSkippedSymlink creates a real symlink and verifies the warning
  • TestDeprecatedShareListLinkJSONIncludesWarning verifies deprecation warning in output

Replace fragile string-matching in jsonErrorCode with typed coded
errors set at the point of creation. Add warnings infrastructure
for deprecated commands and skipped symlinks during recursive upload.
Add contract tests that audit the structured output surface and
verify the JSON operation output envelope shape.
@AndreyVMarkelov AndreyVMarkelov merged commit 247e8d6 into master Jun 25, 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.

1 participant