Skip to content

Catches PortValue unknown decoding errors - #1596

Closed
ellbosch wants to merge 1 commit into
developmentfrom
u/ellbosch/2508/unknown-pv-decoding
Closed

ellbosch wants to merge 1 commit into
developmentfrom
u/ellbosch/2508/unknown-pv-decoding

Conversation

@ellbosch

Copy link
Copy Markdown
Contributor

No description provided.

@claude

claude Bot commented Sep 12, 2025

Copy link
Copy Markdown

Code Review for PR #1596: Catches PortValue unknown decoding errors

Summary

This PR adds error handling for unknown decoding errors when parsing PortValue data in the Stitch AI layer derivation logic.

✅ Strengths

  • Good defensive programming: Adding a catch-all case for DecodingError improves robustness
  • Proper error propagation: The error is correctly wrapped in the existing error type hierarchy
  • Consistent error handling pattern: Follows the existing pattern of catching specific error types

⚠️ Issues & Suggestions

1. Typo in log message

In deriveLayer.swift:503, there is a typo: "unkonwn" should be "unknown"

log("SyntaxViewName.deriveLayerData unkonwn decoding error: \(error)")

2. Missing enum case in description

The new .unknown case added to StitchAIParsingError (line 122) needs a corresponding case in the CustomStringConvertible extension (lines 130-151). Add this after line 148:

case .unknown(let string):
    return "Unknown decoding error: \(string)"

3. Consider more specific error information

Instead of using error.localizedDescription, consider extracting more specific information from the DecodingError to aid debugging:

  • typeMismatch: Include the expected type and context
  • valueNotFound: Include the missing value type
  • keyNotFound: Include the missing key name
  • dataCorrupted: Include corruption context

This would provide more actionable error messages for debugging.

🔒 Security Considerations

No security concerns identified. The error handling does not expose sensitive information.

🚀 Performance Considerations

No performance impact - this is purely error handling code that only executes in failure cases.

🧪 Test Coverage

Consider adding unit tests for the new error case to ensure:

  1. DecodingErrors are properly caught and wrapped
  2. The error message is correctly formatted
  3. Silent errors are properly collected

Recommendation

Approve with minor changes - Fix the typo and add the missing description case. The more detailed error extraction is optional but would improve debugging capabilities.

@ellbosch ellbosch closed this Sep 25, 2025
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