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

FgaRequiredParamError: Required parameter apiHost was null or undefined when calling Configuration. #154

Open
6 tasks done
digitaltopo opened this issue Sep 19, 2024 · 12 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest

Comments

@digitaltopo
Copy link

digitaltopo commented Sep 19, 2024

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of OpenFGA and the issue still persists.
  • I have searched the Slack community and have not found a suitable solution or answer.
  • I agree to the terms within the OpenFGA Code of Conduct.

Description

When apiURL parameter is not supplied while initializing the OpenFGA client, we get an error message that suggests using deprecated apiHost parameter:

FgaRequiredParamError: Required parameter apiHost was null or undefined when calling Configuration.

Expectation

The error message should be to supply an appropriate apiUrl parameter, NOT the deprecated apiHost parameter.

Reproduction

import { OpenFgaClient } from '@openfga/sdk';

const openFga = new OpenFgaClient();

OpenFGA SDK version

0.6.3

OpenFGA version

latest

SDK Configuration

javascript

Logs

No response

References

No response

@digitaltopo digitaltopo added the bug Something isn't working label Sep 19, 2024
@Waheedsys
Copy link
Contributor

Hi, could you please assign this issue to me? I'd like to work on it. Thanks!

@Waheedsys
Copy link
Contributor

if i am not mistaken, To modify the OpenFgaClient constructor to handle the situation where the apiURL parameter is not supplied, you'll need to ensure that the validation for the apiURL is correctly integrated.

Add a Validation Check for apiURL: Ensure that if the apiURL is not provided, an appropriate error message is thrown, indicating that the apiURL is required, rather than referring to the deprecated apiHost.

Error Handling: The assertParamExists function checks if the apiUrl parameter is null or undefined and throws an error with the correct message indicating that the apiUrl parameter is required. This aligns with your expectation that the error message should direct the user to provide the apiUrl instead of the deprecated apiHost.

@Waheedsys
Copy link
Contributor

Can I go ahead and open a pull request for this change

@Waheedsys
Copy link
Contributor

Waheedsys commented Oct 1, 2024

image
the changes in the client.ts

@ewanharris
Copy link
Member

👋🏻 Thanks for picking this up @Waheedsys!

I think we'd want to perform this check in the isValid method of Configuration (here).

This is happening because of the existing check. It's slightly awkward as we want to ensure we maintain compatibility for existing users who were setting apiScheme and apiHost (I think the tests should help here), maybe replacing the !this.apiUrl check with !this.apiScheme && !this.apiHost and then assert that the this.apiUrl property exists would achieve what we want?

@Waheedsys
Copy link
Contributor

Hi @ewanharris,

If I’m not mistaken, here are some points to keep in mind while addressing the issue:

Maintain Compatibility: We should ensure that we don't disrupt functionality for users still relying on apiScheme and apiHost.

Adjust the Check: Instead of solely checking for the absence of apiUrl, let's also verify whether both apiScheme and apiHost are missing. If they are, we can then require apiUrl.

Clear Error Messages: If apiUrl is absent and both apiScheme and apiHost are not provided, we should throw a clear error indicating that apiUrl is required. This will help users understand what’s missing.

Validate apiUrl: When apiUrl is provided, we need to ensure it’s well-formed. If it’s not, we should throw an error to guide users.

Check URI Validity: If neither apiUrl nor valid apiScheme and apiHost combinations are supplied, we should throw an appropriate error message.

@ewanharris
Copy link
Member

@Waheedsys absolutely, those all sound correct to me!

@Waheedsys
Copy link
Contributor

Waheedsys commented Oct 2, 2024

@ewanharris who's Mailing Address is required for the Individual Contributor License Agreement
LFX support - https://jira.linuxfoundation.org/plugins/servlet/desk/portal/4/SUPPORT-30278
pull request link - #161

@ewanharris
Copy link
Member

@Waheedsys I believe when signing the individual CLA all details should be your own.

@Waheedsys
Copy link
Contributor

Thank you for the clarification @ewanharris. Unfortunately, I received an email from support stating that this issue has been resolved as "won't do.

@ewanharris
Copy link
Member

@Waheedsys unfortunately I don't have access to the LFX support system. Are you facing issues signing the CLA after clicking the link in this comment?

@Waheedsys
Copy link
Contributor

@ewanharris i have signed the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest
Projects
Status: Ready
Development

No branches or pull requests

4 participants