Skip to content

fix(salesforce): build query/search results via model_validate#163

Merged
peteski22 merged 1 commit into
mainfrom
fix/salesforce-search-records-ty
Jul 3, 2026
Merged

fix(salesforce): build query/search results via model_validate#163
peteski22 merged 1 commit into
mainfrom
fix/salesforce-search-records-ty

Conversation

@peteski22

Copy link
Copy Markdown
Contributor

Summary

QueryRecordsResult and SearchRecordsResult declare their API fields with Field(alias=...) and populate_by_name=True. The tool code constructed them by Python field name (total_size=, search_records=) — valid at runtime, but ty (0.0.56) synthesizes __init__ from the alias only and rejects the field name, which had forced two scoped # ty: ignore[unknown-argument] suppressions.

Fix

Parse the raw API JSON with model_validate instead of hand-mapping fields:

return QueryRecordsResult.model_validate(data)
return SearchRecordsResult.model_validate(data)

The API JSON already carries the aliases (totalSize, searchRecords), and each model's existing _set_success model_validator defaults success=True when the key is absent — so behavior is unchanged. Both ty: ignore suppressions are removed (including the pre-existing one at the former line 168, per the note on #161).

Verification

  • uv run ty check src/apron_toolsAll checks passed! (no diagnostics, no suppressions).
  • uv run pytest tests/providers/salesforce/ → 60 passed.
  • uv run pre-commit run --all-files → all hooks pass.
  • Confirmed defaults still hold via model_validate: missing done/totalSize/searchRecords fall back to model defaults, and an explicit success in the payload is respected (validator only defaults when absent).

Closes #161

QueryRecordsResult and SearchRecordsResult declare their API fields
with Field(alias=...) and populate_by_name=True. Constructing them by
Python field name (total_size=, search_records=) is valid at runtime,
but ty synthesizes __init__ from the alias only and rejects the field
name, forcing scoped ty:ignore suppressions.

Parse the raw API JSON with model_validate instead. The JSON already
carries the aliases (totalSize, searchRecords) and the models'
_set_success validator defaults success=True when absent, so behavior
is unchanged. This removes both ty:ignore[unknown-argument]
suppressions.

Closes #161
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@peteski22, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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 reviews.

How do review limits work?

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

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, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d3c54a35-a9cb-4d50-8b8f-a279d6a225f7

📥 Commits

Reviewing files that changed from the base of the PR and between 98b4a62 and bc3cdaf.

📒 Files selected for processing (1)
  • src/apron_tools/providers/salesforce/tools.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/salesforce-search-records-ty

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the Salesforce provider’s query/search tool implementations to construct QueryRecordsResult and SearchRecordsResult via Pydantic model_validate(...) on the raw API JSON, aligning runtime behavior with ty’s alias-based __init__ modeling and removing the need for # ty: ignore[unknown-argument] suppressions.

Changes:

  • Replace manual QueryRecordsResult(...) construction with QueryRecordsResult.model_validate(response.json()).
  • Replace manual SearchRecordsResult(...) construction with SearchRecordsResult.model_validate(response.json()).
  • Remove the two scoped ty suppressions related to aliased fields (totalSize, searchRecords).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@peteski22 peteski22 merged commit 1e37a2e into main Jul 3, 2026
9 checks passed
@peteski22 peteski22 deleted the fix/salesforce-search-records-ty branch July 3, 2026 13:17
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.

salesforce_search_records: ty flags search_records kwarg (Field alias vs populate_by_name)

2 participants