Skip to content

feat(plugin): Ambient Weather (ambient_weather) - #650

Merged
devjain32 merged 10 commits into
corsairdev:mainfrom
meetbatra:feat/ambient_weather-plugin
Aug 12, 2026
Merged

feat(plugin): Ambient Weather (ambient_weather)#650
devjain32 merged 10 commits into
corsairdev:mainfrom
meetbatra:feat/ambient_weather-plugin

Conversation

@meetbatra

@meetbatra meetbatra commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Description

Adds the Ambient Weather plugin (ambient_weather) for accessing real-time and
historical data from personal Ambient Weather stations via the AmbientWeather.net API.

Auth: API key + application key (no OAuth, query param based).

Key endpoints:

  • List all user devices with latest readings
  • Fetch historical data for a specific device (5/30 min increments, up to 288 records)

Fixes #643

Checklist

Before submitting your PR, please verify the following:

  • I have run pnpm lint and all checks pass (4 pre-existing failures in unrelated files not touched by this PR)
  • I have run pnpm typecheck and there are no TypeScript errors
  • I have run pnpm build and all packages build successfully
  • I have run pnpm test and all tests pass
  • I have added or updated tests where applicable
  • I have added or updated necessary documentation

Screenshots / Demos

Demo (tests passing + code walkthrough): https://drive.google.com/file/d/1ug9Oebe1wboud1o52eeMDU5HOYk7Wklb/view?usp=sharing

Additional Notes

Implementation complete. The 4 lint failures reported by pnpm lint are pre-existing
in unrelated files (explorer/data/plugins.json, demo/mcp/corsair.ts,
www/src/app/oss/u/[username]/page.tsx, www/src/components/landing/menu/site-menu.tsx)
that are not touched by this PR.

Summary by CodeRabbit

New Features

  • Added Ambient Weather integration with API-key authentication.
  • Added device listing and historical weather data retrieval.
  • Added validation for credentials, requests, responses, and query limits.
  • Added support for storing device metadata and historical readings.
  • Added rate-limit handling and automatic server-error retries.
  • Added Ambient Weather to the available provider list.

Tests

  • Added coverage for authentication, API requests, rate limits, endpoints, schemas, and plugin registration.

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@meetbatra is attempting to deploy a commit to the corsair Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the core Changes in packages/corsair label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds the Ambient Weather Corsair plugin with API-key authentication, typed device and historical-data endpoints, response and database schemas, rate-limit handling, package configuration, tests, and provider registration.

Changes

Ambient Weather plugin

Layer / File(s) Summary
Package foundation and data schemas
packages/ambientweather/package.json, packages/ambientweather/tsconfig.json, packages/ambientweather/tsup.config.ts, packages/ambientweather/jest.config.cjs, packages/ambientweather/schema/*, packages/ambientweather/schema.test.ts, packages/corsair/core/constants.ts
Adds package configuration, device and reading schemas, schema metadata, schema tests, and provider registry entries.
Client authentication and error handling
packages/ambientweather/client.ts, packages/ambientweather/error-handlers.ts, packages/ambientweather/api.test.ts
Adds credential packing and parsing, authenticated GET requests, typed API and rate-limit errors, retry classification, and client tests.
Device endpoint contracts and handlers
packages/ambientweather/endpoints/types.ts, packages/ambientweather/endpoints/devices.ts, packages/ambientweather/endpoints/index.ts, packages/ambientweather/api.test.ts
Adds typed device and historical-data operations. The endpoints validate credentials and responses, request Ambient Weather data, optionally persist entities, and test query construction and upserts.
Plugin assembly and public exports
packages/ambientweather/index.ts, packages/ambientweather/api.test.ts
Adds plugin types, endpoint and API-key authentication registration, factory construction, error-handler merging, public exports, and factory registration tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Corsair
  participant AmbientWeatherEndpoint
  participant AmbientWeatherClient
  participant AmbientWeatherAPI
  participant Database
  Corsair->>AmbientWeatherEndpoint: Invoke devices list or getData
  AmbientWeatherEndpoint->>AmbientWeatherClient: Pass credentials and query
  AmbientWeatherClient->>AmbientWeatherAPI: Send authenticated GET request
  AmbientWeatherAPI-->>AmbientWeatherClient: Return device or reading data
  AmbientWeatherClient-->>AmbientWeatherEndpoint: Return validated response
  AmbientWeatherEndpoint->>Database: Optionally upsert devices or readings
  AmbientWeatherEndpoint-->>Corsair: Return endpoint response
Loading

Possibly related PRs

  • corsairdev/corsair#344: Adds a standalone Corsair provider plugin with typed REST clients, endpoint schemas, error handling, package configuration, and provider registration.
  • corsairdev/corsair#632: Adds a provider-specific Corsair integration with a typed client, GET endpoints, schemas, authentication, error handling, and package wiring.
  • corsairdev/corsair#648: Adds a new Corsair provider plugin with client, endpoint, schema, error-handler, package, and registry integrations.

Suggested labels: plugin, bot:round-2

Suggested reviewers: devjain32

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the addition of the Ambient Weather plugin.
Linked Issues check ✅ Passed The changes satisfy [#643] by adding API-key authentication, device listing, latest data, and historical device data retrieval without webhook support.
Out of Scope Changes check ✅ Passed The changes remain within scope for the Ambient Weather plugin, including implementation, schemas, tests, packaging, and provider registration.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces the Ambient Weather scaffold with a functional API-key integration.

  • Adds device-listing and historical-reading endpoints with Zod validation and optional database persistence.
  • Adds Ambient Weather authentication, API error handling, plugin registration, schemas, packaging configuration, and endpoint-level tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/ambientweather/client.ts Replaces the placeholder transport with authenticated AmbientWeather.net requests and normalized API errors.
packages/ambientweather/endpoints/devices.ts Implements device listing and historical-reading retrieval with response validation and opportunistic persistence.
packages/ambientweather/index.ts Registers the two device endpoints, authentication configuration, schemas, metadata, and error handlers.
packages/ambientweather/api.test.ts Exercises both endpoint handlers, request authentication and paths, response parsing, persistence, rate-limit errors, and factory registration.
packages/ambientweather/endpoints/types.ts Defines the public endpoint input and output contracts for device and weather-reading data.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant Corsair
  participant Plugin as Ambient Weather Plugin
  participant API as AmbientWeather.net
  participant DB as Corsair Database
  Caller->>Corsair: devices.list / devices.getData
  Corsair->>Plugin: Bound endpoint with packed credentials
  Plugin->>API: GET with apiKey and applicationKey
  API-->>Plugin: Devices or historical readings
  Plugin->>Plugin: Validate response with Zod
  Plugin->>DB: Upsert devices or readings
  Plugin-->>Caller: Validated response
Loading

Reviews (3): Last reviewed commit: "fix(ambientweather): parse Retry-After H..." | Re-trigger Greptile

Comment thread packages/ambientweather/client.ts Outdated
Comment thread packages/ambientweather/schema.test.ts Outdated
Comment on lines +3 to +20
describe('AmbientWeather schema', () => {
it('declares a semver version', () => {
expect(AmbientWeatherSchema.version).toBeDefined();
expect(AmbientWeatherSchema.version).toMatch(/^\d+\.\d+\.\d+$/);
});

it('declares an entities map', () => {
expect(typeof AmbientWeatherSchema.entities).toBe('object');
expect(AmbientWeatherSchema.entities).not.toBeNull();
expect(Array.isArray(Object.keys(AmbientWeatherSchema.entities))).toBe(
true,
);
for (const entity of Object.values(AmbientWeatherSchema.entities)) {
expect(entity).toBeDefined();
}
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Endpoint behavior remains untested

When CI runs this package, these assertions inspect only schema metadata and never invoke example.get, allowing broken endpoint wiring, request authentication, paths, and response handling to pass the test suite.

Rule Used: Plugin packages must include at least one *.test.t... (source)

Knowledge Base Used: The provider-plugin package pattern

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Plugin PR scorecard — packages/ambientweather

Check Status Notes
R1 — Scope: plugin files only
R2 — Tests with assertions
R3 — Description complete
R3 — Linked issue / claim
R4 — Demo video / recording

Rules: PLUGIN_PR_RULES.md · re-runs on every push

@github-actions github-actions Bot added the gate:failed Plugin PR gate checks failing label Aug 10, 2026
@github-actions

Copy link
Copy Markdown

Hey @meetbatra, thanks for the contribution! 🏴‍☠️ Before a maintainer reviews, please fix the items below — the review re-runs automatically on your next push.

Must fix

  • P1 packages/ambientweather/client.ts:15Placeholder transport breaks integration
    When callers use this plugin, the only registered endpoint sends example/{id} to https://api.example.com instead of exposing the advertised device operations, causing every station-data request to be unavailable or sent to a placeholder service.

Rule Used: Flag boilerplate residue from the plugin generator... (source)

Knowledge Base Used: The provider-plugin package pattern

  • P1 packages/ambientweather/schema.test.ts:20Endpoint behavior remains untested
    When CI runs this package, these assertions inspect only schema metadata and never invoke example.get, allowing broken endpoint wiring, request authentication, paths, and response handling to pass the test suite.

Rule Used: Plugin packages must include at least one *.test.t... (source)

Knowledge Base Used: The provider-plugin package pattern

PR requirements (rules)

  • R3 — Checklist has unchecked boxes
  • R4 — Required in "Screenshots / Demos" before a maintainer reviews

If anything remains after your next push, a bot commit will clean it up; a maintainer always does the final review and merge.

@github-actions github-actions Bot added the bot:round-1 Review bot posted consolidated findings label Aug 10, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ambientweather/client.ts`:
- Around line 54-58: Update makeAmbientWeatherRequest’s catch handling to
preserve ApiError instances and their status and retryAfter metadata instead of
replacing them with metadata-free AmbientWeatherAPIError values. Re-throw
ApiError unchanged, or ensure AmbientWeatherAPIError retains those fields and
update the related handlers to use it for 401/429 classification and
headersRetryAfterMs.
- Around line 14-39: Implement the Ambient Weather authentication contract
across packages/ambientweather/client.ts:14-39 and
packages/ambientweather/index.ts:38-46, 117-135, and 195-207. Use
https://rt.ambientweather.net/v1, add application_key to the api_key account
configuration, resolve both credentials, and append them as apiKey and
applicationKey query parameters. Remove OpenAPI TOKEN usage, bearer/OAuth
authentication, and generator placeholder comments; update each listed index.ts
site as needed to use the new credential flow.

In `@packages/ambientweather/endpoints/example.ts`:
- Around line 6-12: Extend packages/ambientweather/endpoints/example.ts:6-12
with device-list and latest-data endpoint implementations, using GET /v1/devices
for device listings and consuming each device’s lastData for latest readings;
reserve /v1/devices/{macAddress} for historical data only. Update the endpoint
schemas and types in packages/ambientweather/endpoints/types.ts:3-29 to describe
these operations and responses, then register all required operations in
packages/ambientweather/index.ts:86-105 alongside example.get.

In `@packages/ambientweather/webhooks/tenant-matcher.ts`:
- Around line 14-24: Replace the unsupported tenant_external_id webhook matching
in packages/ambientweather/webhooks/tenant-matcher.ts (lines 14-24) with
matching on the documented Ambient Weather delivery identifier, such as
macAddress, and keep the matcher linkType identical to the configured account
field. Remove or update the placeholder OAuth resolver in
packages/ambientweather/webhooks/oauth-tenant-link.ts (lines 9-30) so routing
uses the same persisted identifier and succeeds for actual Ambient Weather
credential payloads.

In `@packages/ambientweather/webhooks/types.ts`:
- Around line 60-65: Update verifyAmbientWeatherWebhookSignature to stop
accepting requests unconditionally: inspect the provider’s supported webhook
authentication behavior, and if no signed protocol exists, return invalid rather
than { valid: true }. Ensure the example.handler registration is removed or
gated so unsigned Ambient Weather webhook requests cannot be accepted or logged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0cd883b0-6cdd-40f7-8e71-916eb8ba2890

📥 Commits

Reviewing files that changed from the base of the PR and between 99ade55 and d14407b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (19)
  • packages/ambientweather/client.ts
  • packages/ambientweather/endpoints/example.ts
  • packages/ambientweather/endpoints/index.ts
  • packages/ambientweather/endpoints/types.ts
  • packages/ambientweather/error-handlers.ts
  • packages/ambientweather/index.ts
  • packages/ambientweather/jest.config.cjs
  • packages/ambientweather/package.json
  • packages/ambientweather/schema.test.ts
  • packages/ambientweather/schema/database.ts
  • packages/ambientweather/schema/index.ts
  • packages/ambientweather/tsconfig.json
  • packages/ambientweather/tsup.config.ts
  • packages/ambientweather/webhooks/example.ts
  • packages/ambientweather/webhooks/index.ts
  • packages/ambientweather/webhooks/oauth-tenant-link.ts
  • packages/ambientweather/webhooks/tenant-matcher.ts
  • packages/ambientweather/webhooks/types.ts
  • packages/corsair/core/constants.ts

Comment thread packages/ambientweather/client.ts Outdated
Comment thread packages/ambientweather/client.ts Outdated
Comment thread packages/ambientweather/endpoints/example.ts Outdated
Comment thread packages/ambientweather/webhooks/tenant-matcher.ts Outdated
Comment on lines +60 to +65
export function verifyAmbientWeatherWebhookSignature(
request: WebhookRequest<AmbientWeatherWebhookPayload>,
secret: string,
): { valid: boolean; error?: string } {
// TODO: Implement webhook signature verification
return { valid: true };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🔴 Critical | 🏗️ Heavy lift

Reject unsigned webhook requests.

verifyAmbientWeatherWebhookSignature always returns valid. It does not inspect request or secret. example.handler therefore accepts and logs a spoofed request with "type": "example".

Implement the provider-supported authentication check before registering this handler. If the provider has no signed webhook protocol, return invalid and do not expose this handler.

Safe interim change
 export function verifyAmbientWeatherWebhookSignature(
 	request: WebhookRequest<AmbientWeatherWebhookPayload>,
 	secret: string,
 ): { valid: boolean; error?: string } {
-	// TODO: Implement webhook signature verification
-	return { valid: true };
+	return {
+		valid: false,
+		error: 'Webhook signature verification is not implemented',
+	};
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function verifyAmbientWeatherWebhookSignature(
request: WebhookRequest<AmbientWeatherWebhookPayload>,
secret: string,
): { valid: boolean; error?: string } {
// TODO: Implement webhook signature verification
return { valid: true };
export function verifyAmbientWeatherWebhookSignature(
request: WebhookRequest<AmbientWeatherWebhookPayload>,
secret: string,
): { valid: boolean; error?: string } {
return {
valid: false,
error: 'Webhook signature verification is not implemented',
};
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ambientweather/webhooks/types.ts` around lines 60 - 65, Update
verifyAmbientWeatherWebhookSignature to stop accepting requests unconditionally:
inspect the provider’s supported webhook authentication behavior, and if no
signed protocol exists, return invalid rather than { valid: true }. Ensure the
example.handler registration is removed or gated so unsigned Ambient Weather
webhook requests cannot be accepted or logged.

@github-actions github-actions Bot added app App / Hub-facing app code docs Docs / Mintlify / markdown changes labels Aug 10, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/plugins/ambientweather/get-credentials.mdx`:
- Around line 30-35: Update docs/plugins/ambientweather/overview.mdx lines 36-39
and scripts/generate-plugin-docs.ts to document a non-argument credential flow,
using the accepted applicationKey field and hidden prompt, stdin, or safe
API-based input instead of exposing keys through process arguments. Update
docs/plugins/ambientweather/get-credentials.mdx lines 30-35 separately with the
same safe setup guidance; this page is not generated automatically.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 88b475f3-10ed-40b8-a19f-ae482f929c75

📥 Commits

Reviewing files that changed from the base of the PR and between d14407b and a4a7b3d.

📒 Files selected for processing (15)
  • demo/mcp/corsair.ts
  • docs/plugins/ambientweather/api.mdx
  • docs/plugins/ambientweather/get-credentials.mdx
  • docs/plugins/ambientweather/overview.mdx
  • packages/ambientweather/api.test.ts
  • packages/ambientweather/client.ts
  • packages/ambientweather/endpoints/devices.ts
  • packages/ambientweather/endpoints/index.ts
  • packages/ambientweather/endpoints/types.ts
  • packages/ambientweather/error-handlers.ts
  • packages/ambientweather/index.ts
  • packages/ambientweather/schema/database.ts
  • packages/ambientweather/tsconfig.json
  • www/src/app/oss/u/[username]/page.tsx
  • www/src/components/landing/menu/site-menu.tsx
💤 Files with no reviewable changes (1)
  • demo/mcp/corsair.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ambientweather/tsconfig.json

Comment thread docs/plugins/ambientweather/get-credentials.mdx Outdated
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

@Dhirenderchoudhary Dhirenderchoudhary removed docs Docs / Mintlify / markdown changes gate:failed Plugin PR gate checks failing labels Aug 11, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ambientweather/schema/database.ts`:
- Around line 67-75: Update pickAmbientWeatherReadingFields to validate the
filtered out object with z.object(AmbientWeatherReadingFields).partial().parse
and return the schema-inferred partial type instead of using a type assertion.
Ensure complete historical records are parsed with AmbientWeatherReading so
dateutc remains required and numeric/raw field types are validated.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 46d1d71b-e4ef-450d-9b58-298ad9349eb9

📥 Commits

Reviewing files that changed from the base of the PR and between a4a7b3d and a2d85e6.

📒 Files selected for processing (9)
  • packages/ambientweather/api.test.ts
  • packages/ambientweather/client.ts
  • packages/ambientweather/endpoints/devices.ts
  • packages/ambientweather/endpoints/types.ts
  • packages/ambientweather/error-handlers.ts
  • packages/ambientweather/schema.test.ts
  • packages/ambientweather/schema/database.ts
  • packages/ambientweather/schema/index.ts
  • packages/corsair/core/constants.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/ambientweather/schema.test.ts
  • packages/corsair/core/constants.ts
  • packages/ambientweather/error-handlers.ts
  • packages/ambientweather/api.test.ts
  • packages/ambientweather/client.ts

Comment on lines +67 to +75
export function pickAmbientWeatherReadingFields(
data: Record<string, unknown>,
): Omit<AmbientWeatherReading, 'macAddress' | 'checkedAt'> {
const out: Record<string, unknown> = {};
for (const key of Object.keys(AmbientWeatherReadingFields)) {
if (key in data) out[key] = data[key];
}
return out as Omit<AmbientWeatherReading, 'macAddress' | 'checkedAt'>;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Return a validated partial field object.

data can omit dateutc, but Line 69 promises that dateutc exists and is a number. Raw values can also have invalid types. This assertion can let an invalid historical record pass TypeScript checks before later persistence fails.

Validate out with z.object(AmbientWeatherReadingFields).partial() and return its inferred type. Parse the complete historical record with AmbientWeatherReading where dateutc must be required.

#!/bin/bash
set -euo pipefail

# Map the package before inspecting selector consumers.
ast-grep outline packages/ambientweather --items all --type function

# Confirm that each consumer validates the complete historical record.
rg -n --type ts -C 4 \
  'pickAmbientWeatherReadingFields\s*\(|AmbientWeatherReading\.(parse|safeParse)\s*\(' \
  packages/ambientweather
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ambientweather/schema/database.ts` around lines 67 - 75, Update
pickAmbientWeatherReadingFields to validate the filtered out object with
z.object(AmbientWeatherReadingFields).partial().parse and return the
schema-inferred partial type instead of using a type assertion. Ensure complete
historical records are parsed with AmbientWeatherReading so dateutc remains
required and numeric/raw field types are validated.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ambientweather/client.ts`:
- Around line 75-92: Ensure Ambient Weather request URLs contain only one API
version segment: update endpoint values passed by every
makeAmbientWeatherRequest caller to be relative paths such as /devices, or
remove /v1 from AMBIENTWEATHER_API_BASE, then keep buildAmbientWeatherUrl
consistent with that single convention.
- Around line 132-139: Update the Retry-After parsing near retryAfterHeader to
accept non-negative numeric delta-seconds and, when numeric parsing is invalid
or negative, parse the header as an HTTP date and convert it to a non-negative
millisecond delay relative to the current time. Preserve undefined for invalid
dates or otherwise unusable values, and remove the current Number-only handling.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ec2007e-58e2-48b0-bcc9-eb87df32a1f9

📥 Commits

Reviewing files that changed from the base of the PR and between 201ffce and f708d0a.

📒 Files selected for processing (4)
  • packages/ambientweather/api.test.ts
  • packages/ambientweather/client.ts
  • packages/ambientweather/endpoints/devices.ts
  • packages/ambientweather/schema/database.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/ambientweather/api.test.ts
  • packages/ambientweather/endpoints/devices.ts

Comment thread packages/ambientweather/client.ts
Comment thread packages/ambientweather/client.ts Outdated
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

@github-actions github-actions Bot added the bot:round-2 Review bot pushed an automated fix label Aug 11, 2026
@github-actions

Copy link
Copy Markdown

Remaining findings are being fixed by a bot commit — it will be re-reviewed automatically.

@devjain32
devjain32 merged commit 7f81e99 into corsairdev:main Aug 12, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app App / Hub-facing app code bot:round-1 Review bot posted consolidated findings bot:round-2 Review bot pushed an automated fix core Changes in packages/corsair

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin: Ambient Weather(ambient_weather)

3 participants