You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "juliansyahrifqi (via GitHub)" <gi...@apache.org> on 2024/05/30 09:24:03 UTC

[I] There was an error loading the schemas [superset]

juliansyahrifqi opened a new issue, #28778:
URL: https://github.com/apache/superset/issues/28778

   ### Bug description
   
   First, I  added a database into the superset and it works.
   
   But when I tried to add new dataset, I select the database that I added before and when I select the schemas it doesn't show all schemas but it show an message  `There was an error loading the schemas`
   
   I'm using superset v3.0.0
   
   ### How to reproduce the bug
   
   1. Go to menu `dataset`
   2. Click `+ Dataset`
   3. Select`Database`
   4. Select `Schema`
   5. Popup error is show with message `There was an error loading the schemas`
   
   ### Screenshots/recordings
   
   ![image](https://github.com/apache/superset/assets/42226797/612ff7eb-e437-41fd-96f5-23132202a06f)
   
   
   ### Superset version
   
   3.1.3
   
   ### Python version
   
   3.11
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2142888549

   @juliansyahrifqi Could you upgrade to 3.1.3 and see if the error still happens? 3.0.0 is not supported anymore. Please check our [Release Process](https://github.com/apache/superset/wiki/Release-Process) for more information.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "Quiago (via GitHub)" <gi...@apache.org>.
Quiago commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2455516257

   Thanks I'll try
   
   On Mon, Nov 4, 2024, 1:43 AM Rifqi Pratama ***@***.***> wrote:
   
   > Hello
   >
   > host    all             all             0.0.0.0/0            scram-sha-256
   >
   > I just change the scram-sha-256 to be md5 and then reconnect again
   >
   > host    all             all             0.0.0.0/0            md5
   >
   > After it working, i change it again to scram-sha-256
   >
   > host    all             all             0.0.0.0/0            scram-sha-256
   >
   > —
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/superset/issues/28778#issuecomment-2453925666>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AQHNJWJZMQLYTC5SPGLE6LDZ64JSNAVCNFSM6AAAAABIQRHNRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJTHEZDKNRWGY>
   > .
   > You are receiving this because you commented.Message ID:
   > ***@***.***>
   >
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "buraktunca (via GitHub)" <gi...@apache.org>.
buraktunca commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2289845154

   hi, what you changed in .conf file


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "juliansyahrifqi (via GitHub)" <gi...@apache.org>.
juliansyahrifqi commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2144148628

   I already upgrade to v3.1.3 and the error still happens


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2139152774

   <!-- Greeting -->
   Hey there, @juliansyahrifqi! I'm here to help you with the issue you're experiencing. I can assist you in solving bugs, answering questions, and becoming a contributor. Let's work together to resolve the issue you've encountered.
   
   <!-- Answer -->
   To resolve the error "There was an error loading the schemas" when trying to select a schema after adding a new dataset in Apache Superset, ensure the following:
   
   1. **Error Handling in `useSchemas` Hook**:
      Ensure that the `handleError` function is properly handling the error and that the `useSchemas` hook is correctly fetching the schemas. Here is the relevant part of the code:
   
      ```tsx
      const {
        data: schemaData,
        isFetching: loadingSchemas,
        refetch: refetchSchemas,
      } = useSchemas({
        dbId: currentDb?.value,
        catalog: currentCatalog?.value,
        onSuccess: (schemas, isFetched) => {
          if (schemas.length === 1) {
            changeSchema(schemas[0]);
          } else if (
            !schemas.find(schemaOption => schemaRef.current === schemaOption.value)
          ) {
            changeSchema(undefined);
          }
   
          if (isFetched) {
            addSuccessToast('List refreshed');
          }
        },
        onError: () => handleError(t('There was an error loading the schemas')),
      });
      ```
   
      Ensure that the `handleError` function is correctly defined and passed as a prop to the `DatabaseSelector` component:
   
      ```tsx
      function handleError(msg: string) {
        console.error(msg);
        addDangerToast(msg);
      }
   
      <DatabaseSelector
        handleError={handleError}
        // other props
      />
      ```
   
   2. **AJAX Request Handling**:
      Ensure that the AJAX request in the HTML template is correctly handling errors:
   
      ```html
      <script nonce="{{ macros.get_nonce() }}">
        var db = $("#database");
        var schema = $("#schema");
   
        var any_schema_is_allowed = schema.clone();
   
        update_schemas_allowed_for_csv_upload(db.val());
        db.change(function () {
          update_schemas_allowed_for_csv_upload(db.val());
        });
   
        function update_schemas_allowed_for_csv_upload(db_id) {
          $.ajax({
            method: "GET",
            url: `/api/v1/database/${db_id}/schemas_access_for_file_upload/`,
            dataType: 'json',
            contentType: "application/json; charset=utf-8"
          }).done(function (data) {
            change_schema_field_in_formview(data ? data.schemas : [])
          }).fail(function (error) {
            var errorMsg = error.responseJSON.error;
            alert("ERROR: " + errorMsg);
          });
        }
   
        function escape(htmlStr) {
          return htmlStr.replace(/&/g, "&amp;")
            .replace(/</g, "&lt;")
            .replace(/>/g, "&gt;")
            .replace(/"/g, "&quot;")
            .replace(/'/g, "&#39;");
        }
   
        function change_schema_field_in_formview(schemas_allowed) {
          if (schemas_allowed && schemas_allowed.length > 0) {
            var dropdown_schema_lists = '<select id="schema" name="schema" required>';
            schemas_allowed.forEach(function (schema_allowed) {
              dropdown_schema_lists += (
                `<option value="${escape(schema_allowed)}">${escape(schema_allowed)}</option>`
              );
            });
            dropdown_schema_lists += '</select>';
            $("#schema").replaceWith(dropdown_schema_lists);
          } else {
            $("#schema").replaceWith(any_schema_is_allowed)
          }
        }
      </script>
      ```
   
   3. **Database Connection and Schema Access Configuration**:
      Ensure that the database schema access is correctly configured in the backend. The relevant schema definitions and validation logic are defined in `superset/databases/schemas.py`:
   
      ```py
      database_schemas_query_schema = {
          "type": "object",
          "properties": {
              "force": {"type": "boolean"},
              "catalog": {"type": "string"},
          },
      }
   
      database_catalogs_query_schema = {
          "type": "object",
          "properties": {"force": {"type": "boolean"}},
      }
   
      database_tables_query_schema = {
          "type": "object",
          "properties": {
              "force": {"type": "boolean"},
              "schema_name": {"type": "string"},
              "catalog_name": {"type": "string"},
          },
          "required": ["schema_name"],
      }
      ```
   
   By ensuring that both the `handleError` function in your React component and the error handling in the AJAX request are properly defined, and that the database connection and schema access configurations are correctly set up, you can handle the error and display an appropriate message when there is an issue loading the schemas <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/components/DatabaseSelector/index.tsx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/templates/superset/form_view/database_schemas_selector.html)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset/databases/schemas.py)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "Quiago (via GitHub)" <gi...@apache.org>.
Quiago commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2453510511

   Hi, what you changed in .conf file?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "juliansyahrifqi (via GitHub)" <gi...@apache.org>.
juliansyahrifqi commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2144322612

   The error is from PostgreSQL, after i change the config in `pg_hba.conf`, now it working. Thank you


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "juliansyahrifqi (via GitHub)" <gi...@apache.org>.
juliansyahrifqi closed issue #28778: There was an error loading the schemas
URL: https://github.com/apache/superset/issues/28778


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] There was an error loading the schemas [superset]

Posted by "juliansyahrifqi (via GitHub)" <gi...@apache.org>.
juliansyahrifqi commented on issue #28778:
URL: https://github.com/apache/superset/issues/28778#issuecomment-2453925666

   Hello
   
   ```
   host    all             all             0.0.0.0/0            scram-sha-256
   ```
   
   I just change the `scram-sha-256` to be `md5` and then reconnect again
   ```
   host    all             all             0.0.0.0/0            md5
   ```
   
   After it working, i change it again to `scram-sha-256`
   ```
   host    all             all             0.0.0.0/0            scram-sha-256
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org