Skip to content

Commit a3ef685

Browse files
ref: Remove SENTRY_DUMP_REPONSE environment variable (#2212)
We do not appear to use the output generated by SENTRY_DUMP_RESPONSE anywhere. The code only appears to be there for debugging/development purposes, so developers can add it back as needed. No need to ship this code to end users.
1 parent c9d83eb commit a3ef685

File tree

3 files changed

+2
-36
lines changed

3 files changed

+2
-36
lines changed

CONTRIBUTING.md

-6
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,3 @@ let _assemble = mock_endpoint(
6262
.with_response_file("debug_files/post-difs-assemble.json"),
6363
);
6464
```
65-
66-
If you don't know what APIs will be hit during your test, register the test as normal, using `register_test` helper,
67-
and run it in isolation, eg. `cargo test command_debug_files_upload`.
68-
This will store all original API responses under `dump/` directory (controlled via. `SENTRY_DUMP_RESPONSES` env property set
69-
in `tests/integration/mod`), where all path separators `/` are replaced with double underscore `__`.
70-
This way you can simply copy the JSON files to `_responses` directory and update the data as needed.

src/api/mod.rs

+2-29
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ use std::borrow::Cow;
1515
use std::cell::RefCell;
1616
use std::collections::{HashMap, HashSet};
1717
use std::ffi::OsStr;
18-
use std::fs::{create_dir_all, File};
18+
use std::fmt;
19+
use std::fs::File;
1920
use std::io::{self, Read, Write};
2021
use std::path::Path;
2122
use std::rc::Rc;
2223
use std::sync::Arc;
23-
use std::{env, fmt};
2424

2525
use anyhow::{Context, Result};
2626
use backoff::backoff::Backoff;
@@ -42,7 +42,6 @@ use serde::{Deserialize, Serialize};
4242
use sha1_smol::Digest;
4343
use symbolic::common::DebugId;
4444
use symbolic::debuginfo::ObjectKind;
45-
use url::Url;
4645
use uuid::Uuid;
4746

4847
use crate::api::errors::ProjectRenamedError;
@@ -1841,15 +1840,6 @@ impl ApiResponse {
18411840
if let Some(ref body) = self.body {
18421841
let body = String::from_utf8_lossy(body);
18431842
debug!("body: {}", body);
1844-
1845-
// Internal helper for making it easier to write integration tests.
1846-
// Should not be used publicly, as it may be removed without prior warning.
1847-
// Accepts a relative or absolute path to the directory where responses should be stored.
1848-
if let Ok(dir) = env::var("SENTRY_DUMP_RESPONSES") {
1849-
if let Err(err) = dump_response(dir, &self.url, body.into_owned()) {
1850-
debug!("Could not dump a response: {}", err);
1851-
};
1852-
}
18531843
}
18541844
if self.ok() {
18551845
return Ok(self);
@@ -1991,23 +1981,6 @@ fn log_headers(is_response: bool, data: &[u8]) {
19911981
}
19921982
}
19931983

1994-
fn dump_response(mut dir: String, url: &str, body: String) -> Result<()> {
1995-
if dir.starts_with('~') {
1996-
dir = format!(
1997-
"{}{}",
1998-
dirs::home_dir().unwrap_or_default().display(),
1999-
dir.trim_start_matches('~')
2000-
);
2001-
}
2002-
let filename = Url::parse(url)?.path().trim_matches('/').replace('/', "__");
2003-
create_dir_all(&dir)?;
2004-
let filepath = format!("{}/{}.json", &dir, filename);
2005-
let mut file = File::create(&filepath)?;
2006-
file.write_all(&body.into_bytes())?;
2007-
debug!("Response dumped to: {}", &filepath);
2008-
Ok(())
2009-
}
2010-
20111984
#[derive(Debug, Deserialize)]
20121985
#[serde(rename_all = "lowercase")]
20131986
enum ErrorInfo {

tests/integration/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub fn register_test_without_token(path: &str) -> TestCases {
3939
let server_addr = mockito::server_address();
4040
test_case
4141
.env("SENTRY_INTEGRATION_TEST", "1")
42-
.env("SENTRY_DUMP_RESPONSES", "dump") // reused default directory of `trycmd` output dumps
4342
.env("SENTRY_URL", server_url())
4443
.env("SENTRY_ORG", "wat-org")
4544
.env("SENTRY_PROJECT", "wat-project")

0 commit comments

Comments
 (0)