Skip to content

Conversation

@PotatoWKY
Copy link
Contributor

Problem

Remote connection failed due to not able to refresh the status of a newly created App because it is not mapped to the space corresponding to it.

image

Solution

ListApp instead of DescribeApp when the space doesn't have a App mapping to it


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@PotatoWKY PotatoWKY requested a review from a team as a code owner November 5, 2025 01:42
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@PotatoWKY PotatoWKY changed the title fix(SMUS): unble to refresh status on newly created App bug fix(smus): unble to refresh status on newly created App bug Nov 5, 2025
@PotatoWKY PotatoWKY closed this Nov 5, 2025
@PotatoWKY PotatoWKY reopened this Nov 5, 2025
Comment on lines 112 to 128
let app
if (this.spaceApp.App?.AppName) {
app = await this.client.describeApp({
DomainId: this.spaceApp.DomainId,
AppName: this.spaceApp.App?.AppName,
AppType: this.spaceApp?.SpaceSettingsSummary?.AppType,
SpaceName: this.spaceApp.SpaceName,
})
} else if (this.spaceApp.DomainId && this.spaceApp.SpaceName) {
app = await this.client.getAppBySpace(this.spaceApp.DomainId, this.spaceApp.SpaceName)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add unit tests?

Comment on lines +36 to +43
if (!this.spaceApp.App) {
this.spaceApp.App = spaceApp.App
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Under what circumstances will this apply, and what problem is this addressing?

Copy link
Contributor Author

@PotatoWKY PotatoWKY Nov 6, 2025

Choose a reason for hiding this comment

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

this resolve the edge case when this.spaceApp.App is null.
where it is unable to update the status of the app if app is null because current logic to update the app is only updating it's status as a string, if the App object itself is null, then we can not update its status

public setSpaceStatus(spaceStatus: string, appStatus: string) {
    this.spaceApp.Status = spaceStatus
    if (this.spaceApp.App) {
        this.spaceApp.App.Status = appStatus
    }
}

}

public updateSpace(spaceApp: SagemakerSpaceApp) {
if (!this.spaceApp.App) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment to clarify when this will happen, finding it hard to understand.

I know not from this change but spaceApp.App just feels very confusing, if there is scope to rename to better variables, we should.

Copy link
Contributor Author

@PotatoWKY PotatoWKY Nov 6, 2025

Choose a reason for hiding this comment

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

True, do you have any suggestions to replace "spaceApp", basically spaceApp is a space that have a App as one of the variables attached to it.

we would also need to change the name for the SagemakerSpaceApp type:

export interface SagemakerSpaceApp extends SpaceDetails {
    App?: AppDetails
    DomainSpaceKey: string
}

Copy link
Contributor Author

@PotatoWKY PotatoWKY Nov 6, 2025

Choose a reason for hiding this comment

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

what about type: "SagemakerSpaceDetails", variable just: "space" or "spaceDetails"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just noticed that SagemakerSpace is the class name, so the current naming can be more confusing, like:

SagemakerSpace.spaceApp.App.AppName

a lot of spaces and apps

what about:
SagemakerSpace.spaceDetails.appDetails.AppName

this.contextValue = this.getContext()
}

public updateSpace(spaceApp: SagemakerSpaceApp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When all is this invoked and why does it help in this case?

SpaceName: this.spaceApp.SpaceName,
})
let app
if (this.spaceApp.App?.AppName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add comments to clarify such conditional statements. Helps preserve context

})
} else if (this.spaceApp.DomainId && this.spaceApp.SpaceName) {
app = await this.client.getAppBySpace(this.spaceApp.DomainId, this.spaceApp.SpaceName)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

else? Are there other possible cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no other cases, gonna add error handling for else case

return this.makeRequest(DeleteAppCommand, request)
}

public async getAppBySpace(domainId: string, spaceName: string): Promise<AppDetails | undefined> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit : Can just rename this to listAppsForSpace so it describes what it does.

const appsList = await this.listApps({ DomainIdEquals: domainId, SpaceNameEquals: spaceName })
.flatten()
.promise()
return appsList[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess currently it is one app for a space, add a comment to clarify maybe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes current one app for one space, gonna add inline comment

Comment on lines 137 to 133
// AWS DescribeSpace API returns full details with property names like 'SpaceSettings'
// but our internal SagemakerSpaceApp type expects 'SpaceSettingsSummary' (from ListSpaces API)
// We destructure and rename properties to maintain type compatibility
Copy link
Contributor

Choose a reason for hiding this comment

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

Given this, should we just make the above List alone? IIUC they are calling DescribeApp and then converting response to mach ListApps response structure? Am I understanding this wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

Might simplify the above logic if so, thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point.

I think we may want to do use ListSpaces alone for spaces two:
now we are converting SpaceSettings (DescribeSpace) to SpaceSettingsSummary (ListSpace).

so we get rid of the DescribeApp, and only ListApps?:

let app
if (this.spaceApp.DomainId && this.spaceApp.SpaceName) {
    app = await this.client.listAppForSpace(this.spaceApp.DomainId, this.spaceApp.SpaceName)
} else {
    logger.error(
        `updateSpaceAppStatus: unable to get app, [AppName: ${this.spaceApp.App?.AppName}], [DomainId: ${this.spaceApp.DomainId}], [SpaceName: ${this.spaceApp.SpaceName}]`
    )
    throw new ToolkitError(
        `Cannot update app status without [AppName: ${this.spaceApp.App?.AppName}] or [DomainId: ${this.spaceApp.DomainId} and SpaceName: ${this.spaceApp.SpaceName}]`
    )
}

@PotatoWKY PotatoWKY force-pushed the master branch 2 times, most recently from bb83761 to 01db476 Compare November 8, 2025 00:27
assert.strictEqual(updateSpaceArgs.SpaceSharingSettingsSummary, undefined)
})

it('should use listAppForSpace when AppName is not available', async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

No longer the same condition but feel free to update in some other PR.

Copy link
Contributor

@vpbhargav vpbhargav left a comment

Choose a reason for hiding this comment

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

Please test for both SMUS and SM AI thoroughly.

Comment on lines 118 to 128
let app
if (this.spaceApp.DomainId && this.spaceApp.SpaceName) {
app = await this.client.listAppForSpace(this.spaceApp.DomainId, this.spaceApp.SpaceName)
} else {
logger.error(
`updateSpaceAppStatus: unable to get app, [DomainId: ${this.spaceApp.DomainId}], [SpaceName: ${this.spaceApp.SpaceName}]`
)
throw new ToolkitError(
`Cannot update app status without [DomainId: ${this.spaceApp.DomainId} and SpaceName: ${this.spaceApp.SpaceName}]`
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

const app = (this.spaceApp.DomainId && this.spaceApp.SpaceName) ? await this.client.listAppForSpace(this.spaceApp.DomainId, this.spaceApp.SpaceName) : undefined

if (!app) {
     logger.error(
                `updateSpaceAppStatus: unable to get app, [DomainId: ${this.spaceApp.DomainId}], [SpaceName: ${this.spaceApp.SpaceName}]`
            )
            throw new ToolkitError(
                `Cannot update app status without [DomainId: ${this.spaceApp.DomainId} and SpaceName: ${this.spaceApp.SpaceName}]`
            )
}

@PotatoWKY PotatoWKY force-pushed the master branch 3 times, most recently from 8a84918 to 7fd8d39 Compare November 10, 2025 23:39
@Will-ShaoHua Will-ShaoHua merged commit 7a03794 into aws:master Nov 11, 2025
31 checks passed
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.

5 participants