Skip to content

Commit 9c85140

Browse files
nabramovitznorman-abramovitz
authored andcommitted
Fix cloud-foundry test failures from PR #5321
service-catalog-data.service.spec: serviceOffering's two strict-URL expectOne matchers were broken by adding ?return=details to the implementation. Switch to predicate matchers like the broker tests already use. csi-mode.service: narrow isOperationInProgressError so it matches on the "operation in progress" detail string only, not on CF code 10008 (which is the generic CF-UnprocessableEntity covering many unrelated 422 cases). Without this narrowing the bind-error spec that exercises a different 10008 reject ("App is already bound") trips into the polling+retry branch and never settles.
1 parent 5b687eb commit 9c85140

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/frontend/packages/cloud-foundry/src/services/endpoint-data/service-catalog-data.service.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ describe('ServiceCatalogDataService', () => {
2929

3030
afterEach(() => httpMock.verify());
3131

32-
it('serviceOffering hits /cf/service_offerings/:cnsi/:offeringGuid', async () => {
32+
it('serviceOffering hits /cf/service_offerings/:cnsi/:offeringGuid?return=details', async () => {
3333
const promise = new Promise<any>(resolve => service.serviceOffering('cnsi-1', 'off-1').subscribe(resolve));
3434

35-
const req = httpMock.expectOne('/pp/v1/cf/service_offerings/cnsi-1/off-1');
35+
const req = httpMock.expectOne(r => r.url === '/pp/v1/cf/service_offerings/cnsi-1/off-1' && r.params.get('return') === 'details');
3636
expect(req.request.method).toBe('GET');
3737
req.flush({ guid: 'off-1', name: 'premium', description: 'd', broker: { guid: 'b-1', name: 'b1' }, tags: [], available: true, cnsiGuid: 'cnsi-1', createdAt: '', updatedAt: '' });
3838

@@ -44,7 +44,7 @@ describe('ServiceCatalogDataService', () => {
4444
it('serviceOffering returns null on 404', async () => {
4545
const promise = new Promise<any>(resolve => service.serviceOffering('cnsi-1', 'missing').subscribe(resolve));
4646

47-
const req = httpMock.expectOne('/pp/v1/cf/service_offerings/cnsi-1/missing');
47+
const req = httpMock.expectOne(r => r.url === '/pp/v1/cf/service_offerings/cnsi-1/missing' && r.params.get('return') === 'details');
4848
req.flush({ message: 'not found' }, { status: 404, statusText: 'Not Found' });
4949

5050
const res = await promise;

src/frontend/packages/cloud-foundry/src/shared/components/add-service-instance/csi-mode.service.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,20 @@ export class CsiModeService {
319319

320320
}
321321

322-
// Detect CF's "operation in progress" reject — code 10008 with status 422.
323-
// CF returns this when a bind / update lands while the SI's last_operation
324-
// is still in progress. Treated as deferred, not failed: the caller polls
325-
// the SI and retries the bind once last_op = succeeded.
322+
// Detect CF's "operation in progress" reject. CF returns 422 with the
323+
// generic CF-UnprocessableEntity title (code 10008) when a bind/update
324+
// lands while the SI's last_operation is still in progress; the
325+
// distinguishing signal is the detail message itself, not the code
326+
// (10008 covers many other cases). Treated as deferred, not failed:
327+
// the caller polls the SI and retries the bind once last_op = succeeded.
326328
function isOperationInProgressError(err: unknown): boolean {
327329
if (!(err instanceof HttpErrorResponse)) return false;
328330
if (err.status !== 422) return false;
329331
const body = err.error;
330332
if (!body || typeof body !== 'object') return false;
331-
const errors = (body as { errors?: Array<{ code?: number; detail?: string }> }).errors;
333+
const errors = (body as { errors?: Array<{ detail?: string }> }).errors;
332334
const first = errors?.[0];
333-
if (first?.code === 10008) return true;
334-
if (typeof first?.detail === 'string' && first.detail.includes('operation in progress')) return true;
335-
return false;
335+
return typeof first?.detail === 'string' && first.detail.includes('operation in progress');
336336
}
337337

338338
function extractErrorMessage(err: unknown): string {

0 commit comments

Comments
 (0)