-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix environment #5961
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
Fix environment #5961
Changes from all commits
3dc16ac
f52abdc
bd4e5a2
67cca1c
a6258ed
b5fe76f
b6a56f0
b814f05
63da200
91c6f37
ccf1d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,19 +63,21 @@ pub(crate) fn expand(args: TokenStream, mut item: ItemStruct) -> syn::Result<Tok | |
| let constraint = match values.as_deref() { | ||
| None => quote!(<#ty as ::spacetimedb::rt::EnvironmentValue>::constraint()), | ||
| Some([value]) => { | ||
| quote!(::spacetimedb::spacetimedb_lib::environment::EnvVarType::StringLiteral(#value.into())) | ||
| quote!(::spacetimedb::spacetimedb_lib::db::raw_def::v10::RawEnvVarTypeV10::StringLiteral(#value.into())) | ||
| } | ||
| Some(values) => quote!(::spacetimedb::spacetimedb_lib::environment::EnvVarType::Union( | ||
| ::std::vec![#(#values.into()),*] | ||
| )), | ||
| Some(values) => quote!( | ||
| ::spacetimedb::spacetimedb_lib::db::raw_def::v10::RawEnvVarTypeV10::Union( | ||
| ::std::vec![#(#values.into()),*] | ||
| ) | ||
| ), | ||
| }; | ||
| let constraint = if values.is_some() { | ||
| quote!(<#ty as ::spacetimedb::rt::StringEnvironmentValue>::with_constraint(#constraint)) | ||
| } else { | ||
| constraint | ||
| }; | ||
| declarations.push( | ||
| quote!(::spacetimedb::spacetimedb_lib::environment::EnvironmentDeclaration { | ||
| quote!(::spacetimedb::spacetimedb_lib::db::raw_def::v10::RawEnvironmentDeclarationV10 { | ||
| name: #name.into(), | ||
| ty: #constraint, | ||
| optional: <#ty as ::spacetimedb::rt::EnvironmentValue>::OPTIONAL, | ||
|
|
@@ -96,7 +98,7 @@ pub(crate) fn expand(args: TokenStream, mut item: ItemStruct) -> syn::Result<Tok | |
| } | ||
| let vis = &item.vis; | ||
| let access = format_ident!("{}Access", item.ident.unraw()); | ||
| let symbol = format!("__preinit__20_register_environment_{}", item.ident.unraw()); | ||
| let symbol = "__preinit__20_register_environment_there_can_only_be_one"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Ok(quote! { | ||
| #[allow(non_snake_case)] | ||
| #item | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ serde_json.workspace = true | |
| [dev-dependencies] | ||
| insta.workspace = true | ||
| trybuild.workspace = true | ||
| spacetimedb-lib = { path = "../lib", features = ["test"] } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to fix this before merging, it's what's failing Lints. The |
||
|
|
||
| [lints] | ||
| workspace = true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,11 +97,8 @@ async fn fetch(request: reqwest::RequestBuilder, query: Query) -> anyhow::Result | |
| .body(query.sql()?) | ||
| .send() | ||
| .await?; | ||
| ensure!( | ||
| response.status().is_success(), | ||
| "Environment read failed with HTTP {}", | ||
| response.status() | ||
| ); | ||
| let response = response.error_for_status().context("failed to fetch environment")?; | ||
| // TODO(noa): what are we doing here. what. why are we manually buffering. help me | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the motivation was to enforce that we do not exceed the length limits. Otherwise we'd have to read the whole thing in to check the length. |
||
| let mut body = Vec::new(); | ||
| let limit = MAX_ENV_VARS * (MAX_ENV_KEY_BYTES + MAX_ENV_VALUE_BYTES) * 6 + 64 * 1024; | ||
| let mut stream = response.bytes_stream(); | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anything uses the axum macros anymore. Leftover from a
debug_handler?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I was using it for a
derive(FromRequestParts)that I ended up removing.