Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
doppler config ci (#4214)
Will Hutchinson7a1d6d81d48d
diff --git a/.github/scripts/changed-cloud-storage-doppler-config-bins.sh b/.github/scripts/changed-cloud-storage-doppler-config-bins.shnew file mode 100755index 0000000000..ad21ee97da--- /dev/null+++ b/.github/scripts/changed-cloud-storage-doppler-config-bins.sh@@ -0,0 +1,119 @@+#!/usr/bin/env bash+set -euo pipefail++if [[ $# -lt 1 || $# -gt 2 ]]; then+ echo "Usage: $0 <changed-files> [repo-root]" >&2+ exit 2+fi++changed_files=$1+if [[ ! -f "$changed_files" ]]; then+ echo "Changed files list not found: $changed_files" >&2+ exit 2+fi++if [[ $# -eq 2 ]]; then+ repo_root=$2+elif repo_root="$(git rev-parse --show-toplevel 2>/dev/null)"; then+ :+else+ repo_root=$PWD+fi+repo_root=${repo_root%/}++if [[ ! -d "$repo_root" ]]; then+ echo "Repository root not found: $repo_root" >&2+ exit 2+fi++declare -A crate_paths=()+while IFS= read -r changed_file || [[ -n "$changed_file" ]]; do+ changed_file=${changed_file%$'\r'}+ changed_file=${changed_file#./}++ case "$changed_file" in+ rust/cloud-storage/*/src/config.rs)+ crate_path=${changed_file#rust/cloud-storage/}+ crate_path=${crate_path%/src/config.rs}+ ;;+ rust/cloud-storage/*/src/doppler_config.rs)+ crate_path=${changed_file#rust/cloud-storage/}+ crate_path=${crate_path%/src/doppler_config.rs}+ ;;+ rust/cloud-storage/*/Cargo.toml)+ crate_path=${changed_file#rust/cloud-storage/}+ crate_path=${crate_path%/Cargo.toml}+ ;;+ *)+ continue+ ;;+ esac+ if [[ -n "$crate_path" ]]; then+ crate_paths["$crate_path"]=1+ fi+done < "$changed_files"++if [[ ${#crate_paths[@]} -eq 0 ]]; then+ exit 0+fi++bin_names_file=$(mktemp)+trap 'rm -f "$bin_names_file"' EXIT++for crate_path in "${!crate_paths[@]}"; do+ crate_dir="$repo_root/rust/cloud-storage/$crate_path"+ manifest="$crate_dir/Cargo.toml"+ doppler_config="$crate_dir/src/doppler_config.rs"++ if [[ ! -f "$manifest" || ! -f "$doppler_config" ]]; then+ continue+ fi++ python3 - "$manifest" "$crate_path" >> "$bin_names_file" <<'PY'+import sys+from pathlib import Path++try:+ import tomllib+except ModuleNotFoundError:+ print("python3 with tomllib support is required", file=sys.stderr)+ raise SystemExit(1)++manifest_path = Path(sys.argv[1])+crate_path = sys.argv[2]+doppler_config_path = "src/doppler_config.rs"++try:+ manifest = tomllib.loads(manifest_path.read_text())+except (OSError, tomllib.TOMLDecodeError) as error:+ print(f"Failed to read Cargo manifest for {crate_path}: {error}", file=sys.stderr)+ raise SystemExit(1)++matching_bins = [+ bin_config+ for bin_config in manifest.get("bin", [])+ if bin_config.get("path") == doppler_config_path+]++if not matching_bins:+ print(+ f"cloud-storage crate '{crate_path}' has {doppler_config_path} "+ f"but no [[bin]] with path = \"{doppler_config_path}\" in {manifest_path}",+ file=sys.stderr,+ )+ raise SystemExit(1)++for bin_config in matching_bins:+ bin_name = bin_config.get("name")+ if not bin_name:+ print(+ f"cloud-storage crate '{crate_path}' has a [[bin]] with "+ f"path = \"{doppler_config_path}\" but no name in {manifest_path}",+ file=sys.stderr,+ )+ raise SystemExit(1)+ print(bin_name)+PY+done++LC_ALL=C sort -u "$bin_names_file"diff --git a/.github/workflows/code-check-cloud-storage.yml b/.github/workflows/code-check-cloud-storage.ymlindex 800fc7bab5..be3ef0fe71 100644--- a/.github/workflows/code-check-cloud-storage.yml+++ b/.github/workflows/code-check-cloud-storage.yml@@ -22,6 +22,7 @@ jobs:outputs:should_run: ${{ steps.filter.outputs.should_run }}nextest_filter: ${{ steps.package-filter.outputs.nextest_filter }}+ doppler_config_bins: ${{ steps.package-filter.outputs.doppler_config_bins }}steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83ddwith:@@ -46,6 +47,7 @@ jobs:- '.github/services-config.json'- '.github/scripts/build-cloud-storage-lambdas.sh'- '.github/scripts/build-cloud-storage-lambdas-nix.sh'+ - '.github/scripts/changed-cloud-storage-doppler-config-bins.sh'- .github/workflows/code-check-cloud-storage.yml- name: compute nextest package filterid: package-filter@@ -68,6 +70,15 @@ jobs:changed_files="$(git diff --name-only "$compare_rev" "$GITHUB_SHA")"printf '%s\n' "$changed_files" > /tmp/changed-files+ doppler_config_bins="$("$GITHUB_WORKSPACE/.github/scripts/changed-cloud-storage-doppler-config-bins.sh" /tmp/changed-files "$GITHUB_WORKSPACE")"+ {+ echo 'doppler_config_bins<<__DOPPLER_CONFIG_BINS__'+ if [ -n "$doppler_config_bins" ]; then+ printf '%s\n' "$doppler_config_bins"+ fi+ echo '__DOPPLER_CONFIG_BINS__'+ } >> "$GITHUB_OUTPUT"+# Root cargo/toolchain/CI changes can affect the whole workspace, so run all tests.if printf '%s\n' "$changed_files" | grep -qE '^(rust/rust-toolchain\.toml|flake\.nix|flake\.lock|rust/cloud-storage/Cargo\.(toml|lock)|rust/cloud-storage/\.cargo/.*|\.github/actions/(setup-rust|setup-cachix|setup-sccache)/.*|\.github/workflows/code-check-cloud-storage\.yml)$'; thenecho "Workspace-level change detected; running all tests"@@ -107,6 +118,53 @@ jobs:shared-key: cloud-storage-checkcache-on-failure: truecache-targets: false+ - name: validate Doppler configs+ if: needs.path-check.outputs.doppler_config_bins != ''+ env:+ DOPPLER_CONFIG_BINS: ${{ needs.path-check.outputs.doppler_config_bins }}+ DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID || secrets.AWS_ACCESS_KEY }}+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}+ AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}+ run: |+ set -euo pipefail++ if [ -z "${DOPPLER_TOKEN:-}" ]; then+ echo "DOPPLER_TOKEN secret is required to validate Doppler configs" >&2+ exit 1+ fi++ if [ -z "${RUSTC_WRAPPER:-}" ]; then+ echo "RUSTC_WRAPPER is required so Doppler config binaries build through sccache" >&2+ exit 1+ fi++ bins=()+ cargo_args=(build --locked --all-features)+ while IFS= read -r bin; do+ if [ -z "$bin" ]; then+ continue+ fi++ bins+=("$bin")+ cargo_args+=(--bin "$bin")+ done <<< "$DOPPLER_CONFIG_BINS"++ if [ "${#bins[@]}" -eq 0 ]; then+ echo "No Doppler config binaries to validate"+ exit 0+ fi++ echo "Building affected Doppler config binaries with RUSTC_WRAPPER=$RUSTC_WRAPPER"+ printf ' %s\n' "${bins[@]}"++ (+ cd rust/cloud-storage+ cargo "${cargo_args[@]}"+ for bin in "${bins[@]}"; do+ "./target/debug/$bin"+ done+ )- name: fmtrun: cd rust/cloud-storage && cargo fmt --check- name: clippydiff --git a/flake.nix b/flake.nixindex 73679de930..0dceceb252 100644--- a/flake.nix+++ b/flake.nix@@ -171,10 +171,24 @@version = "0.1.0";strictDeps = true;buildInputs = libraries;- nativeBuildInputs = with pkgs; [ pkg-config ] ++ pkgs.lib.optionals isLinux [ mold ];+ # Cargo/crane need git in the sandbox to fetch git dependencies.+ # Without this, CI can fall back to host /usr/lib/git-core helpers,+ # which are not ABI-compatible with Nix-provided glibc.+ nativeBuildInputs = with pkgs; [ git pkg-config ] ++ pkgs.lib.optionals isLinux [ mold ];LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";OPENSSL_NO_VENDOR = "1";SQLX_OFFLINE = "true";+ # Keep vendoring independent of the generated src derivation and pin+ # git dependencies so Nix does not fall back to host git helpers in CI.+ cargoVendorDir = craneLib.vendorCargoDeps {+ src = ./rust/cloud-storage;+ cargoLock = ./rust/cloud-storage/Cargo.lock;+ outputHashes = {+ "git+https://github.com/whutchinson98/jsonwebtoken#c8c0d19511a0e7ba9d456e21437a79d321e99f16" = "sha256-jllT52SAIiNpTPg7Vm3wmT79w/CIz9NnVKM81oQq8dM=";+ "git+https://github.com/macro-inc/rig?branch=feat/responses-api-non-strict-tools#6deadfc6f9b432c849ea79733a549f46407530b7" = "sha256-EcmlwqAVXGtbuvozzCOrygoSVipU99mBZK/MrQAIoYg=";+ "git+https://github.com/macro-inc/rs-libreoffice-bindings?rev=056a40ddfac1d9650be30b9f0b4b934e9266c7dc#056a40ddfac1d9650be30b9f0b4b934e9266c7dc" = "sha256-lx/AuxPpCarxdDzogkGudCbE4B2OEt5un4s4gIFt1ek=";+ };+ };RUSTFLAGS = pkgs.lib.optionalString isLinux "-C link-arg=-fuse-ld=mold";# Build deps + workspace + bins in dev profile so the test job (which runs# `cargo nextest` outside the sandbox using the test profile, inheriting dev)@@ -215,6 +229,70 @@});+ cloudStorageCargoToml = builtins.fromTOML (builtins.readFile ./rust/cloud-storage/Cargo.toml);+ cloudStorageWorkspaceMembers =+ cloudStorageCargoToml.workspace.members or (throw "rust/cloud-storage/Cargo.toml is missing workspace.members");++ dopplerConfigBinNames =+ let+ dopplerConfigPath = "src/doppler_config.rs";+ matchingDopplerBins =+ member:+ let+ memberDir = ./rust/cloud-storage + "/${member}";+ manifestFile = memberDir + "/Cargo.toml";+ hasConfig = builtins.pathExists (memberDir + "/src/config.rs");+ hasDopplerConfig = builtins.pathExists (memberDir + "/${dopplerConfigPath}");+ manifest = builtins.fromTOML (builtins.readFile manifestFile);+ matchingBins = builtins.filter (bin: (bin.path or null) == dopplerConfigPath) (manifest.bin or [ ]);+ missingNameError =+ "cloud-storage workspace member '${member}' has a ${dopplerConfigPath} bin without a name";+ matchingBinNames = map (bin: bin.name or (throw missingNameError)) matchingBins;+ in+ if !hasDopplerConfig then+ [ ]+ else if !(builtins.pathExists manifestFile) then+ throw "cloud-storage workspace member '${member}' has ${dopplerConfigPath} but no Cargo.toml"+ else if matchingBinNames == [ ] then+ throw (+ "cloud-storage workspace member '${member}' has ${dopplerConfigPath} "+ + "but no [[bin]] with path = \"${dopplerConfigPath}\""+ )+ else if !hasConfig then+ [ ]+ else+ matchingBinNames;+ in+ pkgs.lib.unique (pkgs.lib.concatMap matchingDopplerBins cloudStorageWorkspaceMembers);++ dopplerConfigBinPackages = builtins.listToAttrs (+ map (+ binName:+ pkgs.lib.nameValuePair "doppler-config-bin-${binName}" (+ craneLib.buildPackage (+ commonArgs+ // {+ # Reuse the dependency-only layer, then compile only this+ # Doppler config binary and the local crates it actually uses.+ inherit cargoArtifacts;+ pname = "cloud-storage-doppler-config-${binName}";+ doCheck = false;+ cargoExtraArgs = pkgs.lib.concatStringsSep " " [+ "--locked"+ "--all-features"+ "--bin ${binName}"+ ];+ }+ )+ )+ ) dopplerConfigBinNames+ );++ dopplerConfigBins = pkgs.symlinkJoin {+ name = "cloud-storage-doppler-config";+ paths = builtins.attrValues dopplerConfigBinPackages;+ };+openApiBins = craneLib.buildPackage (commonArgs// {@@ -741,6 +819,7 @@RUSTDOCFLAGS = "-Dwarnings";});+ doppler-config-bins = dopplerConfigBins;gen-api =letopenApiFiles = pkgs.lib.cleanSourceWith {@@ -788,10 +867,12 @@deployCargoArtifactslambdaDeployCargoArtifactsopenApiBins+ dopplerConfigBinsnextestArchive;default = cargoArtifacts;}+ // dopplerConfigBinPackages// deployServiceBinaryPackages// deployLambdaPackages;diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex 94308c3548..23e53d97c2 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -2601,6 +2601,7 @@ dependencies = ["axum","contacts","database_env_vars",+ "doppler-config","http-body-util","macro_auth","macro_aws_config",@@ -2648,6 +2649,7 @@ dependencies = ["aws-sdk-sqs","axum","database_env_vars",+ "doppler-config","futures","http-body-util","lambda_client",@@ -3593,6 +3595,7 @@ dependencies = ["crm","document_sub_type","documents",+ "doppler-config","dynamodb_client","email","embedding",@@ -3904,9 +3907,9 @@ dependencies = [[[package]]name = "doppler-config"-version = "0.1.1"+version = "0.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a033f09243efd65cf904770c51a0a4c3d45fd6e4cfa71b915e2f948692fb831d"+checksum = "0735f1faf2ddea06f87842ed94efb5355692d5966e9ad5a3fd10ac3cd7ddc027"dependencies = ["reqwest 0.13.4","serde",@@ -8245,7 +8248,7 @@ version = "5.0.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "51e219e79014df21a225b1860a479e2dcd7cbd9130f4defd4bd0e191ea31d67d"dependencies = [- "base64 0.21.7",+ "base64 0.22.1","chrono","getrandom 0.2.17","http 1.4.0",@@ -10634,6 +10637,7 @@ dependencies = ["chrono","comms_db_client","document_sub_type",+ "doppler-config","email_db_client","ensure_exists","futures",diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.tomlindex e2bd647ffc..02a9c305dc 100644--- a/rust/cloud-storage/Cargo.toml+++ b/rust/cloud-storage/Cargo.toml@@ -213,4 +213,4 @@ strum_macros = "0.27.1"unicode-segmentation = "1.9.0"url = "2.5.0"zip = "=2.4.2"-doppler-config = "0.1.1"+doppler-config = "0.1.2"diff --git a/rust/cloud-storage/authentication_service/Cargo.toml b/rust/cloud-storage/authentication_service/Cargo.tomlindex ccb635e369..aa99c566fc 100644--- a/rust/cloud-storage/authentication_service/Cargo.toml+++ b/rust/cloud-storage/authentication_service/Cargo.toml@@ -17,6 +17,10 @@ path = "src/bin/generate_keys.rs"name = "authentication_service_openapi"path = "src/openapi.rs"+[[bin]]+name = "authentication_service_doppler_config"+path = "src/doppler_config.rs"+[features]default = ["rate_limit"]local = []diff --git a/rust/cloud-storage/authentication_service/src/doppler_config.rs b/rust/cloud-storage/authentication_service/src/doppler_config.rsnew file mode 100644index 0000000000..4793cbfb33--- /dev/null+++ b/rust/cloud-storage/authentication_service/src/doppler_config.rs@@ -0,0 +1,31 @@+#![allow(unused)]+#![recursion_limit = "256"]++use macro_env::Environment;++mod config;++const DOPPLER_PROJECT: &str = "authentication-service";++#[tokio::main]+async fn main() -> anyhow::Result<()> {+ let dev = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Develop.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ dev.load::<config::Config>().await?;++ let prd = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Production.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ prd.load::<config::Config>().await?;++ Ok(())+}diff --git a/rust/cloud-storage/contacts_service/Cargo.toml b/rust/cloud-storage/contacts_service/Cargo.tomlindex bc61ddeac0..6844852dc2 100644--- a/rust/cloud-storage/contacts_service/Cargo.toml+++ b/rust/cloud-storage/contacts_service/Cargo.toml@@ -13,6 +13,10 @@ path = "src/main.rs"name = "contacts_service_openapi"path = "src/openapi.rs"+[[bin]]+name = "contacts_service_doppler_config"+path = "src/doppler_config.rs"+[dependencies]anyhow = { workspace = true }aws-sdk-secretsmanager = { workspace = true }@@ -45,6 +49,7 @@ workspace-hack = { version = "0.1", path = "../workspace-hack" }macro_env_var = { path = "../macro_env_var" }macro_config = { path = "../macro_config" }database_env_vars = { path = "../macro_env_vars/database_env_vars" }+doppler-config = { workspace = true }[features]mock = []diff --git a/rust/cloud-storage/contacts_service/src/doppler_config.rs b/rust/cloud-storage/contacts_service/src/doppler_config.rsnew file mode 100644index 0000000000..af431b745a--- /dev/null+++ b/rust/cloud-storage/contacts_service/src/doppler_config.rs@@ -0,0 +1,31 @@+#![allow(unused)]+#![recursion_limit = "256"]++use macro_env::Environment;++mod config;++const DOPPLER_PROJECT: &str = "contacts-service";++#[tokio::main]+async fn main() -> anyhow::Result<()> {+ let dev = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Develop.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ dev.load::<config::Config>().await?;++ let prd = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Production.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ prd.load::<config::Config>().await?;++ Ok(())+}diff --git a/rust/cloud-storage/convert_service/Cargo.toml b/rust/cloud-storage/convert_service/Cargo.tomlindex 59db50fbf4..f58acbb1a6 100644--- a/rust/cloud-storage/convert_service/Cargo.toml+++ b/rust/cloud-storage/convert_service/Cargo.toml@@ -1,9 +1,14 @@[package]+default-run = "convert_service"edition = "2024"name = "convert_service"publish = falseversion = "0.1.0"+[[bin]]+name = "convert_service_doppler_config"+path = "src/doppler_config.rs"+[features]disable_cleanup = []disable_worker = []@@ -17,6 +22,7 @@ aws-sdk-secretsmanager = { workspace = true }aws-sdk-sqs = { workspace = true }axum = { workspace = true }database_env_vars = { path = "../macro_env_vars/database_env_vars" }+doppler-config = { workspace = true }futures = { workspace = true }http-body-util = { workspace = true }lambda_client = { path = "../lambda_client" }diff --git a/rust/cloud-storage/convert_service/src/doppler_config.rs b/rust/cloud-storage/convert_service/src/doppler_config.rsnew file mode 100644index 0000000000..851962cfb4--- /dev/null+++ b/rust/cloud-storage/convert_service/src/doppler_config.rs@@ -0,0 +1,31 @@+#![allow(unused)]+#![recursion_limit = "256"]++use macro_env::Environment;++mod config;++const DOPPLER_PROJECT: &str = "convert-service";++#[tokio::main]+async fn main() -> anyhow::Result<()> {+ let dev = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Develop.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ dev.load::<config::Config>().await?;++ let prd = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Production.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ prd.load::<config::Config>().await?;++ Ok(())+}diff --git a/rust/cloud-storage/document_storage_service/Cargo.toml b/rust/cloud-storage/document_storage_service/Cargo.tomlindex 4546a16607..7b2c99da2a 100644--- a/rust/cloud-storage/document_storage_service/Cargo.toml+++ b/rust/cloud-storage/document_storage_service/Cargo.toml@@ -13,6 +13,11 @@ path = "src/main.rs"name = "document_storage_service_openapi"path = "src/openapi.rs"+[[bin]]+name = "document_storage_service_doppler_config"+path = "src/doppler_config.rs"++[features]connection_gateway = []default = ["connection_gateway", "location_check"]@@ -151,6 +156,7 @@ uuid = { workspace = true }zip = { workspace = true }workspace-hack = { version = "0.1", path = "../workspace-hack" }macro_config = { path = "../macro_config" }+doppler-config = { workspace = true }[dev-dependencies]cool_asserts = "2"diff --git a/rust/cloud-storage/document_storage_service/src/doppler_config.rs b/rust/cloud-storage/document_storage_service/src/doppler_config.rsnew file mode 100644index 0000000000..661971e178--- /dev/null+++ b/rust/cloud-storage/document_storage_service/src/doppler_config.rs@@ -0,0 +1,31 @@+#![allow(unused)]+#![recursion_limit = "256"]++use macro_env::Environment;++mod config;++const DOPPLER_PROJECT: &str = "cloud-storage-service";++#[tokio::main]+async fn main() -> anyhow::Result<()> {+ let dev = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Develop.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ dev.load::<config::Config>().await?;++ let prd = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Production.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ prd.load::<config::Config>().await?;++ Ok(())+}diff --git a/rust/cloud-storage/macro_config/src/lib.rs b/rust/cloud-storage/macro_config/src/lib.rsindex 58cd1ecdc7..4de7b1633c 100644--- a/rust/cloud-storage/macro_config/src/lib.rs+++ b/rust/cloud-storage/macro_config/src/lib.rs@@ -100,6 +100,50 @@ whereConfigLoader::load()}+#[doc(hidden)]+pub fn __deserialize_missing_field<'de, T, E>(key: &'static str) -> Result<T, E>+where+ T: serde::Deserialize<'de>,+ E: de::Error,+{+ T::deserialize(MissingConfigValueDeserializer {+ key,+ _error: std::marker::PhantomData,+ })+}++struct MissingConfigValueDeserializer<E> {+ key: &'static str,+ _error: std::marker::PhantomData<E>,+}++impl<'de, E> de::Deserializer<'de> for MissingConfigValueDeserializer<E>+where+ E: de::Error,+{+ type Error = E;++ fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>+ where+ V: Visitor<'de>,+ {+ Err(E::missing_field(self.key))+ }++ fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>+ where+ V: Visitor<'de>,+ {+ visitor.visit_none()+ }++ serde::forward_to_deserialize_any! {+ bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string bytes+ byte_buf unit unit_struct newtype_struct seq tuple tuple_struct map struct enum+ identifier ignored_any+ }+}+/// Reads the value from app secrets json env var./// If `APP_SECRETS_JSON` is not present, tries to read from standard env var.fn read_config_value(key: &'static str) -> Option<String> {diff --git a/rust/cloud-storage/macro_config/src/test.rs b/rust/cloud-storage/macro_config/src/test.rsindex f6afe19ba6..3ea1cdb193 100644--- a/rust/cloud-storage/macro_config/src/test.rs+++ b/rust/cloud-storage/macro_config/src/test.rs@@ -250,6 +250,21 @@ struct BareMaybeEnvVarConfig {null_optional_secret: OptionalConfigSecret,}+#[derive(Debug, MacroConfig)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+struct SparseBareMaybeEnvVarConfig {+ optional_config_secret: OptionalConfigSecret,+ missing_optional_secret: OptionalConfigSecret,+ null_optional_secret: OptionalConfigSecret,+}++#[derive(Debug, MacroConfig)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+struct SparseRequiredEnvVarConfig {+ #[allow(dead_code)]+ config_secret: ConfigSecret,+}+#[test]fn load_deserializes_bare_maybe_env_var_fields_without_option_wrapper() {let _lock = ENV_LOCK.lock().expect("env lock poisoned");@@ -295,6 +310,30 @@ fn load_deserializes_bare_maybe_env_var_fields_from_app_secrets_json() {assert_eq!(config.null_optional_secret.value(), None);}+#[test]+fn sparse_deserialization_treats_missing_bare_maybe_env_var_as_unset() {+ let config = serde_json::from_value::<SparseBareMaybeEnvVarConfig>(serde_json::json!({+ "OPTIONAL_CONFIG_SECRET": "from-map",+ "NULL_OPTIONAL_SECRET": null,+ }))+ .expect("sparse config should deserialize");++ assert_eq!(config.optional_config_secret.value(), Some("from-map"));+ assert_eq!(config.missing_optional_secret.value(), None);+ assert_eq!(config.null_optional_secret.value(), None);+}++#[test]+fn sparse_deserialization_still_errors_for_missing_required_env_var() {+ let error = serde_json::from_value::<SparseRequiredEnvVarConfig>(serde_json::json!({}))+ .expect_err("missing required env var should still fail");++ assert!(+ error.to_string().contains("missing field `CONFIG_SECRET`"),+ "unexpected error: {error}"+ );+}+#[test]fn load_deserializes_local_or_remote_macro_env_var_fields() {let _lock = ENV_LOCK.lock().expect("env lock poisoned");diff --git a/rust/cloud-storage/macro_config_derive/src/lib.rs b/rust/cloud-storage/macro_config_derive/src/lib.rsindex e201ba50fb..1a50574130 100644--- a/rust/cloud-storage/macro_config_derive/src/lib.rs+++ b/rust/cloud-storage/macro_config_derive/src/lib.rs@@ -118,6 +118,7 @@ fn expand_macro_config(input: DeriveInput) -> syn::Result<TokenStream2> {let finalizers = field_data.iter().map(|field| {let FieldData {ident,+ ty,key,default,is_option,@@ -132,9 +133,10 @@ fn expand_macro_config(input: DeriveInput) -> syn::Result<TokenStream2> {let #ident = #ident.unwrap_or(None);},None => quote! {- let #ident = #ident.ok_or_else(|| {- <V::Error as ::macro_config::__serde::de::Error>::missing_field(#key)- })?;+ let #ident = match #ident {+ Some(value) => value,+ None => ::macro_config::__deserialize_missing_field::<#ty, V::Error>(#key)?,+ };},}});diff --git a/rust/cloud-storage/search_processing_service/Cargo.toml b/rust/cloud-storage/search_processing_service/Cargo.tomlindex 26138c1527..ae1b90f0f9 100644--- a/rust/cloud-storage/search_processing_service/Cargo.toml+++ b/rust/cloud-storage/search_processing_service/Cargo.toml@@ -15,6 +15,10 @@ name = "search_processing_service"path = "src/main.rs"required-features = ["processing", "service"]+[[bin]]+name = "search_processing_service_doppler_config"+path = "src/doppler_config.rs"+[dependencies]anyhow = { workspace = true }aws-sdk-dynamodb = { workspace = true }@@ -42,6 +46,7 @@ macro_user_id = { path = "../macro_user_id" }macro_uuid = { path = "../macro_uuid" }mention_utils = { path = "../mention_utils" }document_sub_type = { path = "../document_sub_type" }+doppler-config = { workspace = true }model = { path = "../model" }s3_key = { path = "../s3_key" }models_email = { path = "../models_email" }diff --git a/rust/cloud-storage/search_processing_service/src/doppler_config.rs b/rust/cloud-storage/search_processing_service/src/doppler_config.rsnew file mode 100644index 0000000000..7e6e238645--- /dev/null+++ b/rust/cloud-storage/search_processing_service/src/doppler_config.rs@@ -0,0 +1,31 @@+#![allow(unused)]+#![recursion_limit = "256"]++use macro_env::Environment;++mod config;++const DOPPLER_PROJECT: &str = "search-processing-service";++#[tokio::main]+async fn main() -> anyhow::Result<()> {+ let dev = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Develop.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ dev.load::<config::Config>().await?;++ let prd = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Production.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ prd.load::<config::Config>().await?;++ Ok(())+}