Under the Hood: Fixing BFF Outbound API Paths in v0.1.81
Under the Hood: Fixing BFF Outbound API Paths in v0.1.81
Release v0.1.81 resolves two silent but impactful bugs in the BFF (Backend-for-Frontend) compatibility layer that were causing all account-type API calls to fail against the AgentOS platform. This post explains what went wrong, what was fixed, and how the codebase is now protected against recurrence.
Background
myProp communicates with AgentOS via a BFF layer located at src/app/api/bff/[...path]/route.ts. The BFF receives requests from the frontend, maps them to AgentOS API calls, and returns structured responses. Getting the outbound paths right is critical — a wrong path means a 404 or silent failure from AgentOS, with no data surfaced to the client.
What Was Wrong
Bug 1: A Legacy Path Prefix That Shouldn't Exist
A helper function called ppPath() was responsible for building the base URL for every outbound API call:
// Before — WRONG
function ppPath(clientName: string, suffix: string): string {
const cn = encodeURIComponent(clientName.trim());
return `/v1/corporate/peopleportal/letmcletting/${cn}${suffix}`;
}
The AgentOS People Portal API does not use this prefix. Every outbound call should use the pattern:
/{clientName}/...
The prefix /v1/corporate/peopleportal/letmcletting/ does not exist on the target API, so every call routed through ppPath() was hitting a dead end.
This affected all vendor, buyer, landlord, contractor, prospect, and search routes. (The messaging routes and accounts/tenant/active were already using the correct direct-path pattern, which is why those features worked.)
Bug 2: Singular Resource Names
In addition to the wrong prefix, all resource path segments used singular names where the AgentOS spec requires plural:
| Resource | Wrong | Correct |
|---|---|---|
| Vendors | /vendor/{id} | /vendors/{id} |
| Buyers | /buyer/{id} | /buyers/{id} |
| Landlords | /landlord/{id}/... | /landlords/{id}/... |
| Prospects | /prospect/tenant/{id} | /prospects/tenant/{id} |
What Was Fixed
The ppPath(), ppGet(), ppPost(), and ppPatch() helpers have been fully removed. Every route now calls letmcClient.get/post/patch directly with the correct path:
// After — CORRECT
const data = await letmcClient.get(
`/${encodePath(clientName)}/vendors/${encodeURIComponent(vendorID)}`
);
This is the same pattern already in use by the messaging routes and the tenant/active route. All routes in the BFF layer are now consistent.
Full Path Corrections
| BFF Route | Old Outbound Path | New Outbound Path |
|---|---|---|
accounts/vendor | /v1/corporate/.../vendor/{id} | /{clientName}/vendors/{id} |
accounts/buyer | /v1/corporate/.../buyer/{id} | /{clientName}/buyers/{id} |
accounts/buyer/offer | /v1/corporate/.../buyer/{id}/offer | /{clientName}/buyers/{id}/offer |
accounts/landlord/insights | /v1/corporate/.../landlord/{id}/insights | /{clientName}/landlords/{id}/insights |
accounts/landlord/maintenance-jobs | /v1/corporate/.../landlord/{id}/maintenance-jobs | /{clientName}/landlords/{id}/maintenance-jobs |
accounts/landlord/maintenance-job-notes | /v1/corporate/.../landlord/{id}/maintenance-jobs/{jobID}/notes | /{clientName}/landlords/{id}/maintenance-jobs/{jobID}/notes |
accounts/landlord/rent-arrears | /v1/corporate/.../landlord/{id}/rent-arrears | /{clientName}/landlords/{id}/rent-arrears |
accounts/landlord/reports/* | /v1/corporate/.../landlord/{id}/reports/... | /{clientName}/landlords/{id}/reports/... |
accounts/landlord/statements/* | /v1/corporate/.../landlord/{id}/statements/... | /{clientName}/landlords/{id}/statements/... |
accounts/tenant/prospect | /v1/corporate/.../prospect/tenant/{id} | /{clientName}/prospects/tenant/{id} |
company/search | /v1/corporate/.../search | /{clientName}/search |
Regression Prevention
A new test suite at tests/app/api/bff/route.test.ts was added alongside the fix. The tests assert:
- Each BFF route resolves to the correct outbound path
- No outbound path contains the legacy prefix string
- The removed helper functions are no longer present in the codebase
This ensures any future edits to the BFF route file that reintroduce an incorrect path will be caught immediately in CI.
Impact
After this fix, all account data flows — landlord statements, rent arrears reports, maintenance jobs, buyer offers, vendor lookups, and prospect records — correctly reach the AgentOS API and return data to the portal.