Skip to content

fix(dynamo-gen): use robust DateTime check in UnixTimestampTypeHandler#78

Merged
Im5tu merged 1 commit into
mainfrom
fix/dynamo-unixtimestamp-handler-check
Jun 18, 2026
Merged

fix(dynamo-gen): use robust DateTime check in UnixTimestampTypeHandler#78
Im5tu merged 1 commit into
mainfrom
fix/dynamo-unixtimestamp-handler-check

Conversation

@Im5tu

@Im5tu Im5tu commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Context

Follow-up to #74. That PR moved AttributeHandlerRegistry to a robust, symbol-based DateTime/DateTimeOffset check, but UnixTimestampTypeHandler.CanHandle was left on the brittle name-only comparison:

underlyingType.Name == nameof(DateTime) || underlyingType.Name == nameof(DateTimeOffset)

A user-defined type named DateTime (or DateTimeOffset) outside the System namespace would be mistaken for the BCL type.

Change

  • Extract the robust check into a shared ITypeSymbol.IsDateTimeOrDateTimeOffset() extension (SpecialType.System_DateTime for DateTime; type name + System namespace via ToDisplayString() for DateTimeOffset, which has no SpecialType).
  • Use it in both UnixTimestampTypeHandler.CanHandle and AttributeHandlerRegistry — single source of truth, removes the duplicated namespace logic.

Scope notes

Deliberately left untouched (out of scope of this finding):

  • UnixTimestampTypeHandler.GenerateFromDynamoRecord name checks — they run only after CanHandle already confirmed the type, so they select a branch rather than gate.
  • DateTimeTypeHandler / UnixTimestampAttributeHandler name-only checks — pre-existing, unrelated to this finding. The new extension is available to tighten them later.

Validation

  • dotnet build of the generator: clean (0 warnings/errors).
  • dotnet test: 359 passed, 0 failed — including a new regression test that builds a type named DateTime outside System and asserts CanHandle returns false (would have returned true under the old check).

UnixTimestampTypeHandler.CanHandle still gated on brittle name-only
comparisons (underlyingType.Name == nameof(DateTime)/DateTimeOffset)
while AttributeHandlerRegistry already moved to a symbol-based check.
Extract that check into a shared ITypeSymbol.IsDateTimeOrDateTimeOffset
extension (SpecialType for DateTime, name + System namespace for
DateTimeOffset) and use it in both places, so a user-defined type named
DateTime outside System is no longer mistaken for the BCL type.

Adds a regression test covering the spoofed-type case.
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Im5tu, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 17 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3de00abb-77d6-4c71-87a7-91b59ea02c3f

📥 Commits

Reviewing files that changed from the base of the PR and between ce8c084 and ce48d53.

📒 Files selected for processing (4)
  • src/Clients/Goa.Clients.Dynamo.Generator/Attributes/AttributeHandlerRegistry.cs
  • src/Clients/Goa.Clients.Dynamo.Generator/Models/TypeSymbolExtensions.cs
  • src/Clients/Goa.Clients.Dynamo.Generator/TypeHandlers/UnixTimestampTypeHandler.cs
  • tests/Clients/Goa.Clients.Dynamo.Generator.Tests/TypeHandlers/UnixTimestampTypeHandlerTests.cs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dynamo-unixtimestamp-handler-check

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

@Im5tu Im5tu merged commit 3e89cc6 into main Jun 18, 2026
1 of 3 checks passed
@Im5tu Im5tu deleted the fix/dynamo-unixtimestamp-handler-check branch June 18, 2026 12:07
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