Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up to add nav parameter #23845

Merged
merged 13 commits into from
Feb 18, 2025
Merged

Conversation

MarioJGMsoft
Copy link
Contributor

@MarioJGMsoft MarioJGMsoft commented Feb 12, 2025

Description

This task is a follow up to #20323 .

When loop tried to implement the code some errors came up, the expected information was not being added.

Acceptance criteria
The link works properly when loop tries to implement and use it.

Execution plan
Update the methods we are using to receive the appName and the containerPackageName. Also update IODSPResolvedURL to be able to have the containerPackageName.

Reviewer Guidance

Please let me know if there's something that is missing or that I should keep in mind. Thanks!

Fixes: AB#29956

@github-actions github-actions bot added base: main PRs targeted against main branch area: driver Driver related issues area: odsp-driver public api change Changes to a public API labels Feb 12, 2025
@@ -498,7 +486,6 @@ describe("Create New Utils Tests", () => {
false /* forceAccessTokenViaAuthorizationHeader */,
undefined /* isClpCompliantApp */,
true /* enableSingleRequestForShareLinkWithCreate */,
mockOdspResolvedUrl,
),
{
itemId: "mockItemId",
Copy link
Contributor

Choose a reason for hiding this comment

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

After you have made the review changes above, let's add a test with the following flow:

  • initialize OdspDriverUrlResolverForShareLink() and use it to create a resolve the request generated via createOdspCreateContainerRequest
  • mock attach() api response
  • then in the container.resolvedUrl - check if we have all the desired properties.

Checkout examples in odspCreateContainer.spec.ts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since in the unit test, there is no container, you can alternatively check service. resolvedUrl. Service is returned by the createContainer method in the serviceFactory.

@github-actions github-actions bot removed the public api change Changes to a public API label Feb 12, 2025
@github-actions github-actions bot added the public api change Changes to a public API label Feb 12, 2025
@jatgarg jatgarg marked this pull request as ready for review February 18, 2025 22:09
@jatgarg jatgarg requested a review from a team as a code owner February 18, 2025 22:09
@MarioJGMsoft MarioJGMsoft requested a review from a team February 18, 2025 22:26
@MarioJGMsoft MarioJGMsoft requested review from pragya91, markfields, jason-ha, kian-thompson, WillieHabi and rajatch-ff and removed request for a team February 18, 2025 22:26
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> [email protected] serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  160781 links
    1452 destination URLs
    1683 URLs ignored
       0 warnings
       0 errors


@MarioJGMsoft MarioJGMsoft merged commit 3c2d546 into microsoft:main Feb 18, 2025
35 checks passed
@MarioJGMsoft MarioJGMsoft deleted the navParamUpdate branch February 18, 2025 23:20
@@ -82,6 +83,7 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver {
resolvedUrl: IOdspResolvedUrl,
dataStorePath: string,
) => Promise<string | undefined>,
private readonly containerPackageInfo?: IContainerPackageInfo | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

| undefined type shouldn't be needed here since the property is already optional right?

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'm guessing it's there because the call to get context might return undefined, but the function can still exist.

@@ -257,7 +259,8 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver {

const containerPackageName: string | undefined =
getContainerPackageName(packageInfoSource) ??
odspResolvedUrl.codeHint?.containerPackageName;
odspResolvedUrl.codeHint?.containerPackageName ??
getContainerPackageName(this.containerPackageInfo);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment explaining why the chaining here is done.

Something like, "containerPackage information can be either provided via the constructor or to the method's params. We give priority to the locally provided params, and fallback to the constructor provided value" (re-phrase maybe to make it more understandable).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added change

@@ -37,7 +37,7 @@ export function createOdspCreateContainerRequest(
const createNewRequest: IRequest = {
url: `${siteUrl}?driveId=${encodeURIComponent(driveId)}&path=${encodeURIComponent(
filePath,
)}${containerPackageInfo ? `&containerPackageName=${getContainerPackageName(containerPackageInfo)}` : ""}${shareLinkRequestParams ? `&${shareLinkRequestParams}` : ""}`,
)}${shareLinkRequestParams ? `&${shareLinkRequestParams}` : ""}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

@MarioJGMsoft Linter might be unhappy about the unused containerPackageInfo - you can rename the parameter starting with an _ to avoid the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied change


// Compare the values to make sure that the nav parameter was added correctly
assert.equal(
decodedValue,
"s=%2FsiteUrl&d=driveId&f=mockItemId&c=%2F&fluid=1&a=mockAppName&p=mockContainerPackageName&x=mockContext",
"s=%2FsiteUrl&d=driveId&f=itemId&c=%2F&fluid=1&a=appName&p=containerPackageName&x=context",
Copy link
Contributor

Choose a reason for hiding this comment

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

@MarioJGMsoft , Let us also test for scenarios where appName is not provided, but all other params are. Same with containerPackageName. Just to ensure the nav param is not misconstructed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied change

/nav=([^&]*)/,
)?.[1] as string;
// Decode the Base64 value to UTF-8, \r�� is being stored at the end of the string so we slice it off
const decodedValue = fromBase64ToUtf8(base64Value).slice(0, -3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is \r�� coming from?

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'm not sure, it's being added when I decode the value of navParam, so I'm not sure at what point of the code flow it's being added to the encoded nav param. I don't think it can become an issue but let me know if you think otherwise.

@@ -187,6 +187,7 @@ export class OdspDocumentServiceFactoryCore
!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
odspResolvedUrl.isClpCompliantApp,
this.hostPolicy.enableSingleRequestForShareLinkWithCreate,
odspResolvedUrl,
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though it is not related to this PR, I really would like us to change the name of this variable from odspResolveUrl to something else that represents the original name. Something like resolvedUrlForCreateNew. Let me know if that doesn't sound right to you.

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 agree that the name can and should be changed to something more related, but I also think that it might be best to leave that change to another PR. Will create the follow up task for it.

);

const expectedResponse = {
context: "http://sp.devinstall/_api/v2.1/$metadata#",
Copy link
Contributor

@pragya91 pragya91 Feb 19, 2025

Choose a reason for hiding this comment

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

Any reason for using this exact URL? Could we use a dummy one.

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, we could use a dummy one and I added the change.

identityType: "Enterprise",
};

const getContext = async (
Copy link
Contributor

Choose a reason for hiding this comment

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

The function is defined as async, but I don't see any promises used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the constructor of OdspDriverUrlResolverForShareLink, getContext is a function call that returns a Promise of <strin | undefined>, so the getContext function has to be async.

logger,
"appName",
getContext,
{ name: "containerPackageName" },
Copy link
Contributor

Choose a reason for hiding this comment

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

{ name: "containerPackageName" } /*IContainerPackageInfo*/,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied change

// Update the webUrl to the version that has the nav parameter that was supposed to be added
mockSharingLinkData.webUrl =
"https://mock.url/?nav=cz0lMkZzaXRlVXJsJmQ9ZHJpdmVJZCZmPW1vY2tJdGVtSWQmYz0lMkYmZmx1aWQ9MSZhPW1vY2tBcHBOYW1lJnA9bW9ja0NvbnRhaW5lclBhY2thZ2VOYW1lJng9bW9ja0NvbnRleHQ%3D";
const resolved = await shareLinkResolver.resolve(request);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment above this like explaining that we are trying to emulate the 'container' behavior where we first create a resolved object for the provided request to invoke driver's createContainer request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied change

MarioJGMsoft added a commit to MarioJGMsoft/FluidFramework that referenced this pull request Feb 19, 2025
tylerbutler pushed a commit to tylerbutler/FluidFramework that referenced this pull request Feb 22, 2025
## Description

This task is a follow up to
[microsoft#20323](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/20323)
.

When loop tried to implement the code some errors came up, the expected
information was not being added.

Acceptance criteria
The link works properly when loop tries to implement and use it.

Execution plan
Update the methods we are using to receive the appName and the
containerPackageName. Also update IODSPResolvedURL to be able to have
the containerPackageName.

## Reviewer Guidance

Please let me know if there's something that is missing or that I should
keep in mind. Thanks!

Fixes:
[AB#29956](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/29956)

---------

Co-authored-by: Jatin Garg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: driver Driver related issues area: odsp-driver base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants