Skip to content

feat(testing): Option Overrides for testing#50

Merged
hubertdeng123 merged 12 commits intomainfrom
hubertdeng/di-1593-add-test-override-support-for-client-libraries
Mar 5, 2026
Merged

feat(testing): Option Overrides for testing#50
hubertdeng123 merged 12 commits intomainfrom
hubertdeng/di-1593-add-test-override-support-for-client-libraries

Conversation

@hubertdeng123
Copy link
Copy Markdown
Member

No description provided.

@linear
Copy link
Copy Markdown

linear Bot commented Jan 23, 2026

…-for-client-libraries

Resolve merge conflicts:
- main.yml: Keep musl build targets and CLI change detection
- main.py: Merge wrapper function approach with string-option support
- values.json: Keep deletion (values now generated via CLI from examples/configs/)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the best convention to include imports here in init.py, but needed due to packaging purposes for the client

Comment thread .github/workflows/main.yml Outdated
Comment thread .envrc
fi

# Set SENTRY_OPTIONS_DIR to absolute path for tests
export SENTRY_OPTIONS_DIR="${PWD}/sentry-options"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that it doesn't matter which directory you're running python/rust tests

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this belonged here

Comment thread examples/python/main.py
flush=True,
)

def get_string_value():
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes it easier to unit test overrides

@hubertdeng123 hubertdeng123 marked this pull request as ready for review January 30, 2026 00:03
Comment thread clients/python/src/lib.rs Outdated
static GLOBAL_OPTIONS: OnceLock<RustOptions> = OnceLock::new();

// Hook for testing module to register override checker
static OVERRIDE_HOOK: OnceLock<Py<PyAny>> = OnceLock::new();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once testing module is imported, it will set this hook and each get() will use values from python dict that includes overrided values

Comment thread clients/python/src/lib.rs Outdated
impl NamespaceOptions {
/// Get an option value, returning the schema default if not set.
fn get(&self, py: Python<'_>, key: &str) -> PyResult<Py<PyAny>> {
if let Some(value) = get_override(&self.namespace, key) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this overhead should be negligible, there are ways around this but requires overengineering this IMO and don't think that is worth it right now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i understand, so in the rust version, we can compile without the get override stuff for production, but in python, we currently don't allow that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, i tried to make it work well for python but don't think there's a clean way

Comment thread clients/python/python/sentry_options/testing.py
Comment thread clients/python/src/lib.rs Outdated
Comment on lines +17 to +19
thread_local! {
static OVERRIDES: RefCell<HashMap<String, HashMap<String, Value>>> = RefCell::new(HashMap::new());
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps im just lost but is there not a way to use the same OVERRIDES object thats found in rust/src/lib because this library is a wrapper over that anyways?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it cannot, since that is only compiled with the testing feature

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although, now that i am thinking about it wonder if they both should just be consistent lol

Comment thread clients/python/src/lib.rs Outdated
impl NamespaceOptions {
/// Get an option value, returning the schema default if not set.
fn get(&self, py: Python<'_>, key: &str) -> PyResult<Py<PyAny>> {
if let Some(value) = get_override(&self.namespace, key) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i understand, so in the rust version, we can compile without the get override stuff for production, but in python, we currently don't allow that?

Comment thread sentry-options-validation/src/lib.rs
@hubertdeng123 hubertdeng123 merged commit be32bcf into main Mar 5, 2026
22 checks passed
@hubertdeng123 hubertdeng123 deleted the hubertdeng/di-1593-add-test-override-support-for-client-libraries branch March 5, 2026 00:20
hubertdeng123 added a commit that referenced this pull request Mar 9, 2026
…ging

After the module restructuring in #50, maturin stopped inferring the
ABI3 minimum from requires-python and fell back to cp38. Explicitly
passing pyo3/abi3-py311 ensures wheels are tagged abi3-cp311.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hubertdeng123 added a commit that referenced this pull request Mar 9, 2026
…ging (#101)

After the module restructuring in #50, maturin stopped inferring the
ABI3 minimum from requires-python and fell back to cp38. Explicitly
passing pyo3/abi3-py311 ensures wheels are tagged abi3-cp311.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants