Skip to content

Conversation

@Scra3
Copy link
Member

@Scra3 Scra3 commented Jan 15, 2026

Summary

  • Add withDefaultImplementation function that wraps partial ForestAdminServerInterface with a Proxy
  • Methods not implemented in the custom interface will fallback to ForestHttpApi default implementation
  • buildApplicationServices now accepts Partial<ForestAdminServerInterface> instead of full interface

Problem

After PR #1411 (centralize HTTP calls), partial implementations like ForestAdminServerSwitcher in cloud-lambda-layers would fail when calling methods they didn't implement (e.g., checkSchemaHash, postSchema).

The comment in ForestAdminServerSwitcher stated:

"All methods in ForestAdminServerInterface are optional. When not implemented, the agent's default implementation is used."

But this behavior was never actually implemented - there was no fallback mechanism.

Solution

Use a Proxy to intercept method calls on the provided interface:

  1. If the method exists on the custom interface → use it
  2. If not → fallback to the default ForestHttpApi implementation

Test plan

  • All existing tests pass (yarn workspace @forestadmin/forestadmin-client test)
  • Lint passes (yarn workspace @forestadmin/forestadmin-client lint)
  • Build passes (yarn workspace @forestadmin/forestadmin-client build)

🤖 Generated with Claude Code

@qltysh
Copy link

qltysh bot commented Jan 15, 2026

Qlty

Coverage Impact

⬇️ Merging this pull request will decrease total coverage on main by 0.01%.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
packages/forestadmin-client/src/build-application-services.ts92.3%41
Total92.3%
🤖 Increase coverage with AI coding...

In the `feat/server-interface-fallback` branch, add test coverage for this new code:

- `packages/forestadmin-client/src/build-application-services.ts` -- Line 41

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

…erver interfaces

When a partial ForestAdminServerInterface is provided to buildApplicationServices,
methods that are not implemented will now fallback to the default ForestHttpApi
implementation. This allows consumers to override only the methods they need.

This fixes the issue where partial implementations (like ForestAdminServerSwitcher
in cloud-lambda-layers) would fail when calling methods they didn't implement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Scra3 Scra3 force-pushed the feat/server-interface-fallback branch from d438d70 to 17eb01d Compare January 15, 2026 12:26
- Fix tests to verify Proxy behavior through actual services instead of
  calling methods directly
- Add proper Symbol property handling in Proxy's get trap

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants