feat(data-pathways)!: id-keyed pump-state commands + sources metrics shape#217
feat(data-pathways)!: id-keyed pump-state commands + sources metrics shape#217
Conversation
…shape
Mirrors data-pathways v3.0.0:
- New commands: DataPathwayPumpStateFetchBySourceCommand +
DataPathwayPumpStateSaveBySourceCommand hit
/api/v1/pump-states/:pathwayId/sources/:sourceId (GET + PUT). Legacy
flowType-based commands remain for the deprecated route.
- New contract DataPathwayPumpStateBySourceSchema carries sourceId,
flowType (nullable — may be unknown when the source has been removed
from the pathway config), and the state union.
- Throughput/metrics contract: endpoints[url].flowTypes →
endpoints[url].sources (Record<sourceId, {flowType, name?, …}>).
Updated both the exported TThroughputSource shape used in
DataPathwayMetricsSchema and the inline heartbeat input shape on
DataPathwayAssignmentHeartbeatCommand.
- Test coverage: new fetch + save cases for the sourceId-keyed
commands.
BREAKING CHANGE: the metrics throughput shape renames
endpoints[url].flowTypes → endpoints[url].sources keyed by sourceId.
Consumers reading the pathway metrics endpoint or sending heartbeats
must adopt the new shape. Data-pathways v3.0.0 only accepts the new
shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 2 minutes and 18 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRestructures metrics throughput by renaming Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/commands/data-pathways/pump-state.fetch-by-source.ts`:
- Around line 27-29: The getPath method builds a URL with raw path params which
can break for IDs containing slashes or query chars; update protected override
getPath() to encode this.input.pathwayId and this.input.sourceId (e.g., via
encodeURIComponent) before interpolating them into
`/api/v1/pump-states/{pathwayId}/sources/{sourceId}` so the route is safe for
all ID values and preserves the exact parameter values.
In `@src/commands/data-pathways/pump-state.save-by-source.ts`:
- Around line 30-32: The getPath() builder currently interpolates raw user input
into the route, so special/reserved characters in input.sourceId (and pathwayId)
can break the path; update the getPath() method to URL-encode those path
parameters (e.g., apply encodeURIComponent to this.input.sourceId and
this.input.pathwayId) before inserting them into the template string so the
generated route is safe and cannot be manipulated by reserved characters.
🪄 Autofix (Beta)
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
Run ID: 2b1679bb-ddc0-4b47-990d-dcc20c690e8d
📒 Files selected for processing (6)
src/commands/data-pathways/assignment.heartbeat.tssrc/commands/data-pathways/index.tssrc/commands/data-pathways/pump-state.fetch-by-source.tssrc/commands/data-pathways/pump-state.save-by-source.tssrc/contracts/data-pathways.tstest/tests/commands/data-pathways.test.ts
| protected override getPath(): string { | ||
| return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}` | ||
| } |
There was a problem hiding this comment.
Encode path parameters before building the source route.
Raw sourceId interpolation will misroute IDs containing path or query delimiters.
🐛 Proposed fix
protected override getPath(): string {
- return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}`
+ const pathwayId = encodeURIComponent(this.input.pathwayId)
+ const sourceId = encodeURIComponent(this.input.sourceId)
+ return `/api/v1/pump-states/${pathwayId}/sources/${sourceId}`
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/commands/data-pathways/pump-state.fetch-by-source.ts` around lines 27 -
29, The getPath method builds a URL with raw path params which can break for IDs
containing slashes or query chars; update protected override getPath() to encode
this.input.pathwayId and this.input.sourceId (e.g., via encodeURIComponent)
before interpolating them into
`/api/v1/pump-states/{pathwayId}/sources/{sourceId}` so the route is safe for
all ID values and preserves the exact parameter values.
| protected override getPath(): string { | ||
| return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}` | ||
| } |
There was a problem hiding this comment.
Encode path parameters before building the source route.
sourceId is a public string input; reserved characters can change the path/query and target the wrong endpoint.
🐛 Proposed fix
protected override getPath(): string {
- return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}`
+ const pathwayId = encodeURIComponent(this.input.pathwayId)
+ const sourceId = encodeURIComponent(this.input.sourceId)
+ return `/api/v1/pump-states/${pathwayId}/sources/${sourceId}`
}📝 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.
| protected override getPath(): string { | |
| return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}` | |
| } | |
| protected override getPath(): string { | |
| const pathwayId = encodeURIComponent(this.input.pathwayId) | |
| const sourceId = encodeURIComponent(this.input.sourceId) | |
| return `/api/v1/pump-states/${pathwayId}/sources/${sourceId}` | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/commands/data-pathways/pump-state.save-by-source.ts` around lines 30 -
32, The getPath() builder currently interpolates raw user input into the route,
so special/reserved characters in input.sourceId (and pathwayId) can break the
path; update the getPath() method to URL-encode those path parameters (e.g.,
apply encodeURIComponent to this.input.sourceId and this.input.pathwayId) before
inserting them into the template string so the generated route is safe and
cannot be manipulated by reserved characters.
Summary
DataPathwayPumpStateFetchBySourceCommand+DataPathwayPumpStateSaveBySourceCommandhit/api/v1/pump-states/:pathwayId/sources/:sourceId(GET + PUT). Legacy flowType commands stay behind for the deprecated route.DataPathwayPumpStateBySourceSchema(sourceId, flowType nullable, state union).endpoints[url].flowTypes→endpoints[url].sources(keyed bysourceId, carriesflowType+ optionalnameinline). UpdatedTThroughputSourceand the inline heartbeat input type onDataPathwayAssignmentHeartbeatCommand.Tracks
data-pathways@3.0.0. The!marks the metrics breaking change for downstream consumers reading pathway metrics or composing heartbeats directly.Test plan
deno test --allow-allall 229 steps green (new: fetch + save by sourceId)Summary by CodeRabbit
New Features
Tests