Skip to content

fix: make upstream optional in backend-api7 typing#425

Merged
bzp2010 merged 1 commit intomainfrom
feat/optional-upstream
Apr 3, 2026
Merged

fix: make upstream optional in backend-api7 typing#425
bzp2010 merged 1 commit intomainfrom
feat/optional-upstream

Conversation

@jarvis9443
Copy link
Copy Markdown
Contributor

@jarvis9443 jarvis9443 commented Apr 2, 2026

Summary

Make the upstream field optional in the Service interface of backend-api7 typing.

A service may not always have an upstream — for example when using service discovery or plugin-only services. The transformers (ToADC.transformService and FromADC.transformService) already guard against undefined upstream with conditional checks, so the type definition was out of sync with the runtime behavior.

Changes

  • libs/backend-api7/src/typing.ts: Changed upstream: Upstream to upstream?: Upstream

Testing

All existing backend-api7 tests pass (npx nx test backend-api7 — 8/8 tests passed).

Summary by CodeRabbit

  • Improvements
    • Service configuration is now more flexible with upstream settings made optional. This reduces required configuration steps and allows services to be created with fewer mandatory fields.

A service may not have an upstream (e.g. when using service discovery or
plugin-only services). The transformers already guard against undefined
upstream, so this change aligns the type definition with the runtime
behavior.

Ref: api7/api7ee-3-control-plane#2530

Signed-off-by: Nic <qianyong@api7.ai>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jarvis9443 jarvis9443 requested a review from bzp2010 as a code owner April 2, 2026 07:28
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

The upstream property in the Service interface has been made optional, changing from a required field to an optional configuration parameter. This allows Service objects to be instantiated without specifying an upstream value.

Changes

Cohort / File(s) Summary
Type Definition
libs/backend-api7/src/typing.ts
Made upstream property optional in Service interface by changing from upstream: Upstream to upstream?: Upstream.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 An optional upstream path we see,
A property now wild and free,
Configurations light as air,
Services need not always care! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: make upstream optional in backend-api7 typing' directly and clearly summarizes the main change: making the upstream property optional in the Service interface type definition.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/optional-upstream

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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 2, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 left a comment

Choose a reason for hiding this comment

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

This will only apply to the development process; this identifier will not affect runtime behavior in any way, as compilation will result in type erasure. In other words, it simply informs developers that the value might be null and throws an error if there is a type mismatch. If anyone chooses to ignore it, this is of no use.

In any case, this is a positive change.

@bzp2010 bzp2010 merged commit b3ef55f into main Apr 3, 2026
26 checks passed
@bzp2010 bzp2010 deleted the feat/optional-upstream branch April 3, 2026 08:59
@bzp2010 bzp2010 added the test/api7 Trigger the API7 test on the PR label Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test/api7 Trigger the API7 test on the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants