Skip to content
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

feat(schema): Allow integers as username #3328

Merged
merged 4 commits into from
Mar 27, 2024
Merged

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Mar 26, 2024

The django integration sends integers as usernames if the underlying User model returns an integer for get_username() (see issue).

Fixes getsentry/sentry#67601.

@jjbayer jjbayer marked this pull request as ready for review March 26, 2024 16:43
@jjbayer jjbayer requested a review from a team as a code owner March 26, 2024 16:43
Comment on lines +209 to +215
let user = Annotated::new(User {
username: Annotated::new("42".to_string().into()),
..User::default()
});

assert_eq!(user, Annotated::from_json(input).unwrap());
assert_eq!(output, user.to_json().unwrap());
Copy link
Member

Choose a reason for hiding this comment

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

imo the round trip is enough

assert_eq!( Annotated::from_json(input).unwrap().to_json().unwrap(), r#"{"username":"42"}"#)

Can also maybe just use insta here to assert the output?

Copy link
Member Author

Choose a reason for hiding this comment

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

I copy-pasted the existing tests around this, would like to keep them as similar as possible.

@@ -9,6 +9,7 @@
- Extract op and description while converting opentelemetry spans to sentry spans. ([#3287](https://github.com/getsentry/relay/pull/3287))
- Drop `event_id` and `remote_addr` from all outcomes. ([#3319](https://github.com/getsentry/relay/pull/3319))
- Support for AI token metrics ([#3250](https://github.com/getsentry/relay/pull/3250))
- Accept integers in `event.user.username`. ([#3328](https://github.com/getsentry/relay/pull/3328))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: floats are also accepted in LenientString

Suggested change
- Accept integers in `event.user.username`. ([#3328](https://github.com/getsentry/relay/pull/3328))
- Accept numbers in `event.user.username`. ([#3328](https://github.com/getsentry/relay/pull/3328))

@jjbayer jjbayer merged commit 38e7da4 into master Mar 27, 2024
20 checks passed
@jjbayer jjbayer deleted the feat/schema-lenient-username branch March 27, 2024 12:41
jan-auer added a commit that referenced this pull request Mar 28, 2024
* master:
  ref(cardinality): Pipeline Redis script invocations (#3321)
  ref(normalization): Remove StoreProcessor (#3097)
  feat(cardinality): Implement name based cardinality limits (#3313)
  instr(kafka): Tag existing metrics with variant (#3352)
  instr(kafka): More broker stats (#3349)
  instr(kafka): Improve produce error handling (#3351)
  feat(schema): Allow integers as username (#3328)
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.

Allow Django Integration Usernames to be Numbers
4 participants