apache / incubator-hugegraph

A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
https://hugegraph.apache.org
Apache License 2.0
2.63k stars 517 forks source link

[Question] There is no demo of how creating a graph through GraphAPI in test module and I had try client.post() failed. #2530

Closed Github-Polaris closed 4 months ago

Github-Polaris commented 5 months ago

Problem Type (问题类型)

rest-api (结果不合预期)

Before submit

Environment (环境信息)

Your Question (问题描述)

PixPin_2024-04-22_16-29-39 I had tried the client.post() method failed. PixPin_2024-04-22_16-48-02 PixPin_2024-04-22_16-48-27

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

dosubot[bot] commented 5 months ago

嗨,@BreakMeEveryday!看来我们又在这里相遇了,希望这次我能帮到你。我正在查看你的问题,很快会给你一个完整的答复。

Github-Polaris commented 5 months ago

我跑get的方法是对的,所以client这边应该没有问题,是因为我没有配置请求头吗,还是说这里不要用RestClient去请求,而是用普通的http工具?比如hutool下的一些Http工具类去发送请求?

@dosu-bot , 请问动态创建图的 API 在 java-client 或者 HTTP 请求中应该如何构造, 另外请给出动态创建图的 API 代码引用以及相关的测试代码例子

Github-Polaris commented 5 months ago

There is the result after invoking Apifox. PixPin_2024-04-22_17-16-32

imbajin commented 5 months ago

我跑get的方法是对的,所以client这边应该没有问题,是因为我没有配置请求头吗,还是说这里不要用RestClient去请求,而是用普通的http工具?比如hutool下的一些Http工具类去发送请求?

@dosu-bot , 请问动态创建图的 API 在 java-client 或者 HTTP 请求中应该如何构造, 另外请给出动态创建图的 API 代码引用以及相关的测试代码例子

@dosu-bot, please respond promptly to the user's questions based on the previous context

dosubot[bot] commented 5 months ago

To address the issue with the client.post() method and guide you on how to dynamically create a graph using the HugeGraph API, here's a focused approach:

  1. Resolve java.net.UnknownHostException: This error indicates a problem with network connectivity or DNS resolution. Ensure the HugeGraph server URL is correct and accessible from your development environment. Verify network settings, firewall configurations, and DNS resolution to ensure your application can reach the HugeGraph server.

  2. Use HugeClient.builder(url, graph) for Client Configuration: Properly configure your HugeClient instance with the server URL, graph name, and any necessary authentication details. Adjust connection parameters as needed, including timeout settings and SSL configurations if your server uses SSL.

  3. Check Server and Client Dependencies: Ensure the HugeGraph server is correctly configured, especially if using RocksDB, and that all required client dependencies are included in your project.

  4. Dynamic Graph Creation API Usage:

    • To dynamically create a graph, use the following method signature from GraphsAPI.java:
      public Map<String, String> create(String name, String cloneGraphName, String configText) {
       RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_TYPE, "text/plain");
       Map<String, Object> params = null;
       if (StringUtils.isNotEmpty(cloneGraphName)) {
           params = ImmutableMap.of("clone_graph_name", cloneGraphName);
       }
       RestResult result = this.client.post(joinPath(this.path(), name), configText, headers, params);
       return result.readObject(Map.class);
      }
    • Parameters:
      • name: Name of the new graph.
      • cloneGraphName: (Optional) Name of an existing graph to clone.
      • configText: Configuration for the new graph.

This method checks the API version for compatibility and uses the client.post() method with appropriate headers and parameters to create the graph. Ensure your request includes the correct content type and any necessary parameters, such as the name of an existing graph to clone, if applicable.

By following these steps and utilizing the provided API method, you should be able to dynamically create graphs in HugeGraph without encountering the client.post() method failure.

#### Details **Sources** - [hugegraph-client/src/main/java/org/apache/hugegraph/example/SingleExample.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/main/java/org/apache/hugegraph/example/SingleExample.java) - [hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java) - [hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java) - [hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java) - [hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java) - [hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Github-Polaris commented 5 months ago

@dosu Sorry, your answer is not working and there is no 4 parameters overload method with client.post(). This is my solution and it works. 对不起,您的答案不起作用,并且没有带有 client.post() 的 4 个参数重载方法。这是我的解决方案,它有效。

    /**
     * 该Test方法成功,url可以替换成你自己的路径,我只是用了常量定义,HttpUtil使用的是hutool 5.8.27包,这个也可以自定义替换
     * */
    @Test
    public void createGraphUsingHttpUtil(){
        String url = ConstTransferPath.BASE_URL.getPath()
                +ConstTransferPath.GRAPHS.getPath()
                +"hugegraph2";

        String configInfo = "gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy\n" +
                "backend=rocksdb\n" +
                "serializer=binary\n" +
                "store=hugegraph2\n" +
                "rocksdb.data_path=./rks-data-2\n" +
                "rocksdb.wal_path=./rks-data-2";

        try{
            String response = HttpUtil.createPost(url)
                                      .header("Content-Type", "text/plain") //Attention Please! The content-type is text/plain.
                                      .body(configInfo)
                                      .execute()
                                      .body();
            System.out.println(JSONUtil.toJsonPrettyStr(response));
        }catch (Exception e){
            log.error(e.getMessage());
        }
    }
dosubot[bot] commented 5 months ago

Thank you for sharing your solution. It's great to see you've found a way to dynamically create a graph using HttpUtil from the hutool library. Your approach, which involves setting the Content-Type header to text/plain and directly posting the configuration information to the server, is a practical example of interacting with the API. This method is indeed effective for users who prefer or require an alternative to the provided Java client.

For others who might be following this discussion, the key takeaway from @BreakMeEveryday's solution is the importance of correctly setting the Content-Type header and ensuring that the body of the request contains the necessary configuration for creating a new graph. This example also highlights the flexibility of the HugeGraph API, allowing for various HTTP client tools to be used for interaction, not limited to the Java client.

If there are any further questions or if anyone needs additional clarification on working with the HugeGraph API, feel free to ask.

#### Details **About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

imbajin commented 5 months ago

@BreakMeEveryday indeed there are actually 2 problems:

  1. one is why the HTTP-API direct request to create the graph failed
    • A: It seems to be caused by incorrect configuration/parameters/usage. If you are using tools like Postman, please make sure that the parameters are set correctly (If it still doesn't work, please wait for a moment. @ZeeJJ123 we will take some time to take a look and everyone will try to participate in the community when they are time free. Please be patient~ THX)
  2. the other is that the java-client side does not provide an related tests for it (in toolchain -> client)
    • A: Nope, u should check it in toolchain repo, just refer the impl code & test related code) (WIP-🚧). If you are going to create multiple graphs, please consider using client / sending HTTP or simply copying the configuration file locally, then update the configs in /graphs/new-graph.properties & restart server to make it work and avoid blocking here (we have 3 ways to make it work)

BTW, u could try to use docker version to avoid some environmental impacts and run tests quickly

@dosu u need tell users to move/check the toolchain repo for client related issues (they may miss the context if u don't remind them)

Github-Polaris commented 5 months ago

@imbajin @dosu Yeah, I did found the org.apache.hugegraph.api.graphs.GraphsAPI.create(String name, String cloneGraphName, String configText) in hugegraph-client project, it may works and I will give it a try.

A bad news, I'm failed and here is my result. I had run the test method test/java/org.apache.hugegraph.api.GraphsApiTest.testCreateAndDropGraph() in hugegraph-toolchain/hugegraph-client module.

    @Test
    public void testCreateAndDropGraph() {
        int initialGraphNumber = graphsAPI.list().size();

        // Create new graph dynamically
        String config;
        try {
            config = FileUtils.readFileToString(new File(CONFIG2_PATH),
                                                StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new ClientException("Failed to read config file: %s",
                                      CONFIG2_PATH);
        }
        Map<String, String> result = graphsAPI.create(GRAPH2, null, config);
    ...
    }

But a same exception as before occured.

PixPin_2024-04-23_15-48-44

And here is the stack of exceptions of server

java.lang.IllegalStateException: Missing authentication context when verifying resource permission
    at com.google.common.base.Preconditions.checkState(Preconditions.java:532) ~[guava-30.0-jre.jar:?]
    at org.apache.hugegraph.util.E.checkState(E.java:64) ~[hugegraph-common-1.3.0.jar:1.3.0]
    at org.apache.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:964) ~[classes/:?]
    at org.apache.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:955) ~[classes/:?]
    at org.apache.hugegraph.auth.HugeGraphAuthProxy.verifyPermission(HugeGraphAuthProxy.java:828) ~[classes/:?]
    at org.apache.hugegraph.auth.HugeGraphAuthProxy.create(HugeGraphAuthProxy.java:781) ~[classes/:?]
    at org.apache.hugegraph.core.GraphManager.createGraph(GraphManager.java:591) ~[classes/:?]
    at org.apache.hugegraph.core.GraphManager.createGraph(GraphManager.java:188) ~[classes/:?]
    at org.apache.hugegraph.api.profile.GraphsAPI.create(GraphsAPI.java:136) ~[classes/:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ObjectOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:192) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[jersey-common-3.0.3.jar:?]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[jersey-common-3.0.3.jar:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[jersey-common-3.0.3.jar:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274) ~[jersey-common-3.0.3.jar:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:244) ~[jersey-common-3.0.3.jar:?]
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) ~[jersey-common-3.0.3.jar:?]
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684) ~[jersey-server-3.0.3.jar:?]
    at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:356) ~[jersey-container-grizzly2-http-3.0.3.jar:?]
    at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:190) ~[grizzly-http-server-3.0.1.jar:3.0.1]
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535) ~[grizzly-framework-3.0.1.jar:3.0.1]
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515) ~[grizzly-framework-3.0.1.jar:3.0.1]
    at java.lang.Thread.run(Thread.java:829) [?:?]

U know, I did nothing to the username and password and even I didn't touch the username and password since using the HugeGraph.

public class BaseClientTest {
    protected static final String BASE_URL = "http://192.168.10.70:8080";
    protected static final String GRAPH = "hugegraph";
    protected static final String USERNAME = "admin";
    protected static final String PASSWORD = "pa";
...
}
dosubot[bot] commented 5 months ago

The issue you're encountering, indicated by the java.lang.IllegalStateException with the message "Missing authentication context when verifying resource permission," suggests a problem with authentication during your attempt to dynamically create a graph using the HugeGraph API. It appears that the client might not be authenticated or the authentication context is not properly established for the API call.

To address this, ensure your client is authenticated before making any API requests, especially if your HugeGraph server requires authentication. Here's a concise way to authenticate using token-based authentication, which is recommended for security:

  1. Initialize the RestClient with your HugeGraph server's URL.
  2. Use the LoginAPI to log in with your admin credentials and obtain a token.
  3. Set the authentication context of your client with the obtained token.

Here's a simplified example:

import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.auth.Login;
import org.apache.hugegraph.structure.auth.LoginResult;
import org.apache.hugegraph.api.auth.LoginAPI;
import org.apache.hugegraph.api.auth.TokenAPI;

public class YourTestClass {
    private static String BASE_URL = "http://your_hugegraph_server.com";
    private static String GRAPH = "your_graph_name";
    private static RestClient client;

    public static void init() {
        client = RestClient.builder(BASE_URL).build();
        LoginAPI loginAPI = new LoginAPI(client, GRAPH);
        Login login = new Login().name("admin").password("pa");
        LoginResult result = loginAPI.login(login);
        client.setAuthContext("Bearer " + result.token());
    }

    public static void main(String[] args) {
        init();
        // Your client is now authenticated and ready for API calls
    }
}

Make sure to replace "http://your_hugegraph_server.com" and "your_graph_name" with your actual server URL and graph name. Also, confirm that the username and password match those expected by your server.

This setup should resolve the authentication issue. If the problem persists, it might be beneficial to check your HugeGraph server's authentication configuration, particularly the auth.authenticator property in the rest-server.properties file, to ensure it's correctly set up for your authentication method.

#### Details **Sources** - [[Question] 1.2.0 create graph in rest-api throws auth related permission](https://github.com/apache/incubator-hugegraph/issues/2500) - [[Bug] get exception when connecting to HugeGraph ](https://github.com/apache/incubator-hugegraph/issues/2040) - [hg server 添加认证后,client方式创建模式出错.](https://github.com/apache/incubator-hugegraph/issues/640) - [hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java) - [hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java) - [content/cn/docs/config/config-authentication.md](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/cn/docs/config/config-authentication.md) - [content/en/docs/config/config-authentication.md](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/config/config-authentication.md) - [content/en/docs/clients/restful-api/auth.md](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/clients/restful-api/auth.md) - [content/en/docs/changelog/hugegraph-1.3.0-release-notes.md](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/changelog/hugegraph-1.3.0-release-notes.md) - [hugegraph-server/hugegraph-dist/src/assembly/static/conf/rest-server.properties](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/src/assembly/static/conf/rest-server.properties) - [hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java) - [hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

imbajin commented 5 months ago

@imbajin @dosu Yeah, I did found the org.apache.hugegraph.api.graphs.GraphsAPI.create(String name, String cloneGraphName, String configText) in hugegraph-client project, it may works and I will give it a try.

A bad news, I'm failed and here is my result. I had run the test method test/java/org.apache.hugegraph.api.GraphsApiTest.testCreateAndDropGraph() in hugegraph-toolchain/hugegraph-client module.

    @Test
    public void testCreateAndDropGraph() {
        int initialGraphNumber = graphsAPI.list().size();

        // Create new graph dynamically
        String config;
        try {
            config = FileUtils.readFileToString(new File(CONFIG2_PATH),
                                                StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new ClientException("Failed to read config file: %s",
                                      CONFIG2_PATH);
        }
        Map<String, String> result = graphsAPI.create(GRAPH2, null, config);
    ...
    }

But a same exception as before occured.

PixPin_2024-04-23_15-48-44

And here is the stack of exceptions of server

java.lang.IllegalStateException: Missing authentication context when verifying resource permission
  at com.google.common.base.Preconditions.checkState(Preconditions.java:532) ~[guava-30.0-jre.jar:?]
  at org.apache.hugegraph.util.E.checkState(E.java:64) ~[hugegraph-common-1.3.0.jar:1.3.0]
  at org.apache.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:964) ~[classes/:?]
  at org.apache.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:955) ~[classes/:?]
  at org.apache.hugegraph.auth.HugeGraphAuthProxy.verifyPermission(HugeGraphAuthProxy.java:828) ~[classes/:?]
  at org.apache.hugegraph.auth.HugeGraphAuthProxy.create(HugeGraphAuthProxy.java:781) ~[classes/:?]
  at org.apache.hugegraph.core.GraphManager.createGraph(GraphManager.java:591) ~[classes/:?]
  at org.apache.hugegraph.core.GraphManager.createGraph(GraphManager.java:188) ~[classes/:?]
  at org.apache.hugegraph.api.profile.GraphsAPI.create(GraphsAPI.java:136) ~[classes/:?]
  at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
  at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
  at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
  at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
  at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ObjectOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:192) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[jersey-common-3.0.3.jar:?]
  at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[jersey-common-3.0.3.jar:?]
  at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[jersey-common-3.0.3.jar:?]
  at org.glassfish.jersey.internal.Errors.process(Errors.java:274) ~[jersey-common-3.0.3.jar:?]
  at org.glassfish.jersey.internal.Errors.process(Errors.java:244) ~[jersey-common-3.0.3.jar:?]
  at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) ~[jersey-common-3.0.3.jar:?]
  at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684) ~[jersey-server-3.0.3.jar:?]
  at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:356) ~[jersey-container-grizzly2-http-3.0.3.jar:?]
  at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:190) ~[grizzly-http-server-3.0.1.jar:3.0.1]
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535) ~[grizzly-framework-3.0.1.jar:3.0.1]
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515) ~[grizzly-framework-3.0.1.jar:3.0.1]
  at java.lang.Thread.run(Thread.java:829) [?:?]

U know, I did nothing to the username and password and even I didn't touch the username and password since using the HugeGraph.

public class BaseClientTest {
    protected static final String BASE_URL = "http://192.168.10.70:8080";
    protected static final String GRAPH = "hugegraph";
    protected static final String USERNAME = "admin";
    protected static final String PASSWORD = "pa";
...
}

@BreakMeEveryday some suggestions:

  1. Try to input your username/password (auth info) or remember to init it if u didn't set them before
  2. disable the auth function & retry it
  3. use docker version to enable/disable auth in one step
dosubot[bot] commented 5 months ago

Given the error message "Missing authentication context when verifying resource permission," it seems the issue is related to authentication. Here are steps to potentially resolve this:

  1. Ensure Authentication is Configured: If your HugeGraph server has authentication enabled, you need to authenticate your client before making API calls. This involves obtaining a token using your credentials and then using this token for subsequent requests.

  2. Check Authentication Configuration: Verify the rest-server.properties file on your HugeGraph server to ensure that authentication is set up correctly. Look for the auth.authenticator property and confirm it's configured as expected.

  3. Use Correct Credentials: Make sure you are using the correct username and password when attempting to authenticate. Since you mentioned not modifying the username and password, ensure these default credentials are still valid and haven't been changed.

  4. Explicitly Set Authentication in Your Test: If you're running a test that requires authentication, ensure your test code explicitly sets the authentication context. This might involve setting up a login step at the beginning of your test to authenticate and then using the obtained token for your API calls.

  5. Disable Authentication for Testing: If authentication is not essential for your current testing purposes and you're encountering difficulties, consider temporarily disabling authentication on your HugeGraph server. This can help determine if the issue is specifically related to authentication or if there are other problems. Remember to re-enable authentication after testing to ensure your server's security.

  6. Consult Documentation and Community: If the issue persists, consult the HugeGraph documentation and community forums for more detailed guidance on authentication and permission issues. There might be specific configurations or known issues with certain versions that the community can help you address.

Remember, changing server configurations, especially those related to security like authentication, should be done cautiously and ideally in a testing environment before applying changes to production.

#### Details **About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

github-actions[bot] commented 4 months ago

Due to the lack of activity, the current issue is marked as stale and will be closed after 20 days, any update will remove the stale label

imbajin commented 2 weeks ago

refer #2418 & I'll enhance the doc now