-
Notifications
You must be signed in to change notification settings - Fork 112
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
it_works_fetch_post.sql - Test fail on 0.26.0 build. #541
Comments
This test starts a web server listening on port 62802 and then tries to connect to it from sqlpage using the fetch function. I see you are using nix, maybe you have something in your configuration that prevents this from working ? Another reason may be the new ability to use the system's root certificates introduced in this version ? system_root_ca_certificates Can you run this with debug-level logging in SQLPage and post the logs ? Anyway I'll try to add better error messages because I agree |
@guiguid : I added better error messages. Can you run |
Hi, see below. The test doesn't find the system root CA certificates. failures:
---- test_files stdout ----
[2024-08-17T20:43:04Z ERROR sqlpage::webserver::database::sql] Invalid function call to sqlpage.url_encode. SQLPage function arguments must be static if the function is not at the top level of a select statement.
thread 'test_files' panicked at tests/index.rs:158:13:
/tests/sql_test_files/it_works_fetch_post.sql?x=1 <!DOCTYPE html>
<html lang="" style="font-size: 18px" >
<head>
<meta charset="utf-8" />
<title>SQLPage</title>
<link rel="icon" href="/favicon.f7f27adaf87a60c3.svg">
<link rel="stylesheet" href="/sqlpage.481877f5b70a4e4f.css">
<script src="/sqlpage.a49b961fc9e808cb.js" defer nonce="12520308226123946112"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="generator" content="SQLPage" />
</head>
<body class="layout-boxed" >
<div class="page">
<div class="page-wrapper">
<main class="page-body container-xl pt-3 px-md-5 px-sm-3 " id="sqlpage_main_wrapper"><div class="alert alert-danger text-muted mt-2" role="alert">
<p>
<span class="status status-red">
<span class="status-dot status-dot-animated"></span> Error
</span>
We are sorry, but an error occurred while generating this page.
You should contact the site's administrator.
</p>
<p>
</p>
<pre><code>Failed to set the $res variable to StmtWithParams { query: "SELECT CAST(? AS TEXT)", params: [FunctionCall(SqlPageFunctionCall { function: fetch, arguments: [Literal("{\n \"method\": \"POST\",\n \"url\": \"http://localhost:62802/post\",\n \"headers\": {\"x-custom\": \"1\"},\n \"body\": {\"hello\": \"world\"}\n}")] })], delayed_functions: [] }</code></pre>
<details open class="fs-5">
<summary>Backtrace</summary><pre class="fs-5 mt-1 p-1 my-1"><code>Error in function call sqlpage.fetch('{
"method": "POST",
"url": "http://localhost:62802/post",
"headers": {"x-custom": "1"},
"body": {"hello": "world"}
}').
Expected sqlpage.fetch(http_request)</code></pre><pre class="fs-5 mt-1 p-1 my-1"><code>Unable to create an HTTP client</code></pre><pre class="fs-5 mt-1 p-1 my-1"><code>Unable to load native certificates, make sure the system root CA certificates are available: Initial native certificates load failed</code></pre></details>
</div>
</main>
</div>
<footer class="w-100 text-center fs-6 my-2 text-secondary" id="sqlpage_footer">
<!-- You can change this footer using the 'footer' parameter of the 'shell' component -->
Built with <a class="text-reset" href="https://sql.datapage.app"
title="SQLPage v0.27.0">SQLPage</a>
</footer>
</div>
</body>
</html> expected to contain: It works !
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
3: <core::pin::Pin<P> as core::future::future::Future>::poll
4: tokio::runtime::scheduler::current_thread::Context::enter
5: tokio::runtime::context::scoped::Scoped<T>::set
6: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
7: tokio::runtime::context::runtime::enter_runtime
8: tokio::runtime::runtime::Runtime::block_on
9: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
test_files
test result: FAILED. 17 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.48s |
Thanks for the reproduction! Maybe we should instead never use native certificates in the tests. Can you confirm it works when you disable native certificate loading with If it does, can you commit that into a new pull request? |
The test pass with cacert in build env ! |
Sorry, building 54cb2aa without "cacert" and without "SYSTEM_ROOT_CA_CERTIFICATES = false" failed : test test_files ... FAILED
test test_concurrent_requests ... ok
failures:
---- test_files stdout ----
[2024-08-17T21:42:12Z ERROR sqlpage::render] SQL error: The cookie component cannot be used after data has already been sent to the client's browser. This component must be used before any other component. To fix this, either move the call to the 'cookie' component to the top of the SQL file, or create a new SQL file where 'cookie' is the first component.
Stack backtrace:
0: anyhow::error::<impl anyhow::Error>::msg
1: anyhow::__private::format_err
2: sqlpage::render::RenderContext<W>::handle_row::{{closure}}
3: sqlpage::webserver::http::render_sql::{{closure}}::{{closure}}
4: tokio::runtime::task::core::Core<T,S>::poll
5: tokio::runtime::task::harness::Harness<T,S>::poll
6: tokio::task::local::LocalSet::tick
7: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
8: <core::pin::Pin<P> as core::future::future::Future>::poll
9: tokio::runtime::scheduler::current_thread::Context::enter
10: tokio::runtime::context::scoped::Scoped<T>::set
11: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
12: tokio::runtime::context::runtime::enter_runtime
13: tokio::runtime::runtime::Runtime::block_on
14: core::ops::function::FnOnce::call_once
15: test::__rust_begin_short_backtrace
16: test::types::RunnableTest::run
17: test::run_test::{{closure}}
18: std::sys_common::backtrace::__rust_begin_short_backtrace
19: core::ops::function::FnOnce::call_once{{vtable.shim}}
20: std::sys::pal::unix::thread::Thread::new::thread_start
21: start_thread
22: __GI___clone3
[2024-08-17T21:42:12Z ERROR sqlpage::render] SQL error: There cannot be more than a single shell per page.
You are trying to open the "shell" component, but a shell component is already opened for the current page.
You can fix this by removing the extra shell component, or by moving this component to the top of the SQL file, before any other component that displays data.
Stack backtrace:
0: anyhow::error::<impl anyhow::Error>::msg
1: anyhow::__private::format_err
2: sqlpage::render::RenderContext<W>::handle_row::{{closure}}
3: sqlpage::webserver::http::render_sql::{{closure}}::{{closure}}
4: tokio::runtime::task::core::Core<T,S>::poll
5: tokio::runtime::task::harness::Harness<T,S>::poll
6: tokio::task::local::LocalSet::tick
7: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
8: <core::pin::Pin<P> as core::future::future::Future>::poll
9: tokio::runtime::scheduler::current_thread::Context::enter
10: tokio::runtime::context::scoped::Scoped<T>::set
11: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
12: tokio::runtime::context::runtime::enter_runtime
13: tokio::runtime::runtime::Runtime::block_on
14: core::ops::function::FnOnce::call_once
15: test::__rust_begin_short_backtrace
16: test::types::RunnableTest::run
17: test::run_test::{{closure}}
18: std::sys_common::backtrace::__rust_begin_short_backtrace
19: core::ops::function::FnOnce::call_once{{vtable.shim}}
20: std::sys::pal::unix::thread::Thread::new::thread_start
21: start_thread
22: __GI___clone3
thread 'test_files' panicked at tests/index.rs:158:13:
/tests/sql_test_files/it_works_fetch_simple.sql?x=1 <!DOCTYPE html>
<html lang="" style="font-size: 18px" >
<head>
<meta charset="utf-8" />
<title>SQLPage</title>
<link rel="icon" href="/favicon.841573662987894a.svg">
<link rel="stylesheet" href="/sqlpage.2912879b75d7253b.css">
<script src="/sqlpage.776eba1d55073e4e.js" defer nonce="4412969482288585169"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="generator" content="SQLPage" />
</head>
<body class="layout-boxed" >
<div class="page">
<div class="page-wrapper">
<main class="page-body container-xl pt-3 px-md-5 px-sm-3 " id="sqlpage_main_wrapper"><div class="alert alert-danger text-muted mt-2" role="alert">
<p>
<span class="status status-red">
<span class="status-dot status-dot-animated"></span> Error
</span>
We are sorry, but an error occurred while generating this page.
You should contact the site's administrator.
</p>
<p>
</p>
<pre><code>Failed to set the $res variable to StmtWithParams { query: "SELECT CAST(? AS TEXT)", params: [FunctionCall(SqlPageFunctionCall { function: fetch, arguments: [Literal("http://localhost:62802/hello_world")] })], delayed_functions: [] }</code></pre>
<details open class="fs-5">
<summary>Backtrace</summary><pre class="fs-5 mt-1 p-1 my-1"><code>Error in function call sqlpage.fetch('http://localhost:62802/hello_world').
Expected sqlpage.fetch(http_request)</code></pre><pre class="fs-5 mt-1 p-1 my-1"><code>Unable to create an HTTP client</code></pre><pre class="fs-5 mt-1 p-1 my-1"><code>Unable to load native certificates, make sure the system root CA certificates are available: Initial native certificates load failed</code></pre></details>
</div>
</main>
</div>
<footer class="w-100 text-center fs-6 my-2 text-secondary" id="sqlpage_footer">
<!-- You can change this footer using the 'footer' parameter of the 'shell' component -->
Built with <a class="text-reset" href="https://sql.datapage.app"
title="SQLPage v0.27.0">SQLPage</a>
</footer>
</div>
</body>
</html> expected to contain: It works !
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
3: <core::pin::Pin<P> as core::future::future::Future>::poll
4: tokio::runtime::scheduler::current_thread::Context::enter
5: tokio::runtime::context::scoped::Scoped<T>::set
6: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
7: tokio::runtime::context::runtime::enter_runtime
8: tokio::runtime::runtime::Runtime::block_on
9: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
test_files
test result: FAILED. 17 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.41s |
I'm not sure I understand your latest message. Did you try setting system_root_ca_certificates=false in tests/index.rs and still got an error? The default is not just false. The default is to respect environment variables. If environment variables point to a system certificate store, it will be used. In your case, you probably have environment variables pointing to a path that does not exist. And can you post the full TRACE-level logs? You are including irrelevant errors from other tests but not the full logs for the actual problem. If the logs are too large, you can put them on pastebin. |
Sorry, perhaps I don't understand what to do with "system_root_ca_certificates=false" pub fn test_config() -> AppConfig {
let db_url = std::env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite::memory:".to_string());
serde_json::from_str::<AppConfig>(&format!(
r#"{{
"database_url": "{}",
"database_connection_retries": 3,
"database_connection_acquire_timeout_seconds": 15,
"allow_exec": true,
"max_uploaded_file_size": 12345,
"listen_on": "111.111.111.111:1",
"system_root_ca_certificates" : false
}}"#, Do you confirm ? I'll pass RUST_BACKTRACE = full on next try. I've found more log in my previous build: failures:
---- test_official_website_basic_auth_example stdout ----
thread 'test_official_website_basic_auth_example' panicked at tests/index.rs:418:80:
called `Result::unwrap()` on an `Err` value: Unable to load configuration
Caused by:
invalid type: string "", expected a boolean for key `system_root_ca_certificates` in the environment
Stack backtrace:
0: sqlpage::app_config::load_from_file
1: sqlpage::app_config::load_from_directory
2: index::make_app_data_for_official_website::{{closure}}
3: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
4: <core::pin::Pin<P> as core::future::future::Future>::poll
5: tokio::runtime::scheduler::current_thread::Context::enter
6: tokio::runtime::context::scoped::Scoped<T>::set
7: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
8: tokio::runtime::context::runtime::enter_runtime
9: tokio::runtime::runtime::Runtime::block_on
10: core::ops::function::FnOnce::call_once
11: test::__rust_begin_short_backtrace
12: test::types::RunnableTest::run
13: test::run_test::{{closure}}
14: std::sys_common::backtrace::__rust_begin_short_backtrace
15: core::ops::function::FnOnce::call_once{{vtable.shim}}
16: std::sys::pal::unix::thread::Thread::new::thread_start
17: start_thread
18: __GI___clone3
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: index::make_app_data_for_official_website::{{closure}}
4: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
5: <core::pin::Pin<P> as core::future::future::Future>::poll
6: tokio::runtime::scheduler::current_thread::Context::enter
7: tokio::runtime::context::scoped::Scoped<T>::set
8: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
9: tokio::runtime::context::runtime::enter_runtime
10: tokio::runtime::runtime::Runtime::block_on
11: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- test_official_website_documentation stdout ----
thread 'test_official_website_documentation' panicked at tests/index.rs:418:80:
called `Result::unwrap()` on an `Err` value: Unable to load configuration
Caused by:
invalid type: string "", expected a boolean for key `system_root_ca_certificates` in the environment
Stack backtrace:
0: sqlpage::app_config::load_from_file
1: sqlpage::app_config::load_from_directory
2: index::make_app_data_for_official_website::{{closure}}
3: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
4: <core::pin::Pin<P> as core::future::future::Future>::poll
5: tokio::runtime::scheduler::current_thread::Context::enter
6: tokio::runtime::context::scoped::Scoped<T>::set
7: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
8: tokio::runtime::context::runtime::enter_runtime
9: tokio::runtime::runtime::Runtime::block_on
10: core::ops::function::FnOnce::call_once
11: test::__rust_begin_short_backtrace
12: test::types::RunnableTest::run
13: test::run_test::{{closure}}
14: std::sys_common::backtrace::__rust_begin_short_backtrace
15: core::ops::function::FnOnce::call_once{{vtable.shim}}
16: std::sys::pal::unix::thread::Thread::new::thread_start
17: start_thread
18: __GI___clone3
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: index::make_app_data_for_official_website::{{closure}}
4: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
5: <core::pin::Pin<P> as core::future::future::Future>::poll
6: tokio::runtime::scheduler::current_thread::Context::enter
7: tokio::runtime::context::scoped::Scoped<T>::set
8: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
9: tokio::runtime::context::runtime::enter_runtime
10: tokio::runtime::runtime::Runtime::block_on
11: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. Strange, i'll try with "SYSTEM_ROOT_CA_CERTIFICATES = 0" |
Yes I confirm you should set it in the index.rs. Does it work? If so, you can open a pr |
Thanks, this #543 fix the issue. |
Introduction
When building sqlpage 0.26.0 from source, the test "/tests/sql_test_files/it_works_fetch_post.sql?x=1" failed.
So I can't build sqlpage from source.
To Reproduce
Build from source 0.26.0 on nixos from my branch :
https://github.com/guiguid/nixpkgs/blob/guiguid-patch-sqlpage-0.26.0/pkgs/servers/sqlpage/default.nix
Actual behavior
Expected behavior
The build of SQLPage 0.25.0 works passing all tests
Version information
The text was updated successfully, but these errors were encountered: