Skip to content

Type ControlEventSchedulingInfo.priority as a string in TypeScript - #81

Merged
Bre77 merged 1 commit into
mainfrom
feature/eng-4-pw-1-make-priority-a-string-in-tesla-protocol-typescript
Nov 1, 2026
Merged

Bre77 merged 1 commit into
mainfrom
feature/eng-4-pw-1-make-priority-a-string-in-tesla-protocol-typescript

Conversation

@Bre77

@Bre77 Bre77 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Assignee: @Bre77 (bre77)

Resolves ENG-4.

Summary

ControlEventSchedulingInfo.priority is a uint64, and a max-backup event is scheduled at 2^64 - 1. In the generated TypeScript the field was a number. That meant encoding the value threw invalid uint64, and decoding any MessageEnvelope carrying it threw Value is larger than Number.MAX_SAFE_INTEGER, so the whole get_backup_events reply was lost.

  • proto/energy_device/teg_api.proto: uint64 priority = 3 [jstype = JS_STRING];
  • scripts/generate.sh: added useJsTypeOverride=true to TS_OPTS. The bare option has no effect in ts-proto 2.7.7.
  • Regenerated. The TypeScript diff touches only ControlEventSchedulingInfo.priority, which is now string and decoded with reader.uint64().toString(), and removes the longToNumber helper, which nothing uses any more. On the Python side only the serialized descriptor changes; Python ignores jstype.
  • New fixtures/golden/energy_v1r_envelopes.json: the 20 local v1r request envelopes from document 09, plus a get_backup_events reply whose manual backup event has priority 2^64 - 1. Tests are packages/typescript/test/energy-v1r-envelopes.test.ts and packages/python/tests/test_energy_v1r_envelopes.py. Both decode every envelope, check the expected payload is set, re-encode to the same bytes, and check the scheduling info. The TypeScript test also builds the schedule request with priority "18446744073709551615" and gets the golden bytes.
  • The changeset is minor. Under pragmatic versioning that is an ANNOUNCE bump, chosen because the type change breaks TypeScript callers; the wire bytes do not change.

The fixture note on reconnect_grid: the captured bytes include an explicit force = false (10 00). Neither generated encoder writes a proto3 default, so that one entry has a canonical_hex that the re-encode check compares against.

Acceptance

  • The generated priority type is string.
  • Decoding the fixture gives "18446744073709551615". Checked in both the TS and Python tests.
  • The generated TypeScript diff touches only that field and the unused longToNumber helper.
  • buf breaking --against-config buf.yaml passes under WIRE_JSON locally.
  • Catalog totals are unchanged: 1115 messages, 325 enums, 3972 fields. build_catalog.py gives no diff.

Checks run locally

pnpm generate (output is clean and committed), buf lint, buf breaking, upstream_coverage.py --mode pinned, check_reply_coverage.py, test_build_catalog.py, pnpm build, pnpm tsc, node --test (49 pass), and Python unittest (19 pass).


Tip: I will respond to comments that @ mention @cyrusagent on this PR/MR. You can also submit a review with all your feedback at once, and I will automatically wake up to address each comment.

Add [jstype = JS_STRING] to the uint64 priority and enable ts-proto's
useJsTypeOverride=true, so a max-backup priority of 2^64 - 1 no longer
throws on encode or loses the whole get_backup_events reply on decode.
Add the energy_v1r_envelopes golden fixture with TypeScript and Python tests.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@Bre77
Bre77 marked this pull request as ready for review October 31, 2026 22:31
@Bre77
Bre77 merged commit 4f49c2b into main Nov 1, 2026
5 checks passed
@Bre77
Bre77 deleted the feature/eng-4-pw-1-make-priority-a-string-in-tesla-protocol-typescript branch November 1, 2026 11:37
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