Commit Graph

202 Commits

Author SHA1 Message Date
Klaas van Schelven
ae9cb209a5 Create 'bsmain' (for bugsink-main) app to hold commands
As had been noted on some of the commands, 'ingest' was not the best place for
them.  However, [project-level apps are not supported in
Django](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/2)
So just create a 'main' app. I want to qualify it as 'myproject-main' though, to avoid
further unqualified global namespace pollution. And I want to avoid prefixing with 'bugsink'
b/c that's annoying for tab-completion. So 'bs' it is.

I've moved all commands over; even though a case could be made that the "feeding" commands
(raise_exception, send_json, stress_test) are somewhat related to ingestion, that's not
a very good case :-)
2025-01-23 11:55:34 +01:00
Klaas van Schelven
7727bc6168 Show dsn-as-understood when failing to authenticate in error message
status code for PermissionDenied rather than 404 also
2025-01-22 22:15:53 +01:00
Klaas van Schelven
505cae4b18 fix: don't raise non-existing exception
the previously referred type is from the DRF, but we don't use that
2025-01-17 17:04:28 +01:00
Klaas van Schelven
ed9ffa248d jsonschema check: allow for .values to be missing
see #16
2024-12-16 11:23:55 +01:00
Klaas van Schelven
b597d91af7 Become robust for lack of .values key in exception
Fix #16
2024-12-16 11:22:32 +01:00
Klaas van Schelven
f7280eaf75 flake8 2024-11-28 14:34:01 +01:00
Klaas van Schelven
ad3e758822 When Dogfooding, monkey-path MAX_DATABAG_* constants
See https://github.com/getsentry/sentry-python/issues/3209 for why
2024-11-28 14:28:35 +01:00
Klaas van Schelven
95c9dfa7a1 Use fastjsonschema's detailed_exceptions=False
We don't use fastjsonschema's exception info, falling back to jsonschema for that. Not using the info is faster.
Possible because https://github.com/horejsek/python-fastjsonschema/issues/187 was completed.

I did not at present do any speed/memory checks, but the diff is quite promising :-)
2024-11-28 11:42:16 +01:00
Klaas van Schelven
fa0c3aa325 X-Forwarded-For spoofing tool as an arg; Remove accidentally checked in file 2024-11-22 09:29:27 +01:00
Klaas van Schelven
1ca83bba83 SetRemoteAddrMiddleware for X-Real-IP and X-Forwarded-For 2024-11-21 09:53:16 +01:00
Klaas van Schelven
4a28c51b6a Tests: Add known-broken handling for events that are invalid on purpose 2024-11-15 11:20:12 +01:00
Klaas van Schelven
3222c0d85e Fix the tests (missing initial data in transactiontestcase) 2024-11-15 10:14:01 +01:00
Klaas van Schelven
0f60dab032 phone-home: on (docker) server-start too 2024-11-11 14:37:27 +01:00
Klaas van Schelven
488b52ea04 prestart command (simplying the throwaway Docker install) 2024-11-06 09:38:54 +01:00
Klaas van Schelven
1755fa32c0 Envelope parsing: push exception about lack of errors up into parser
fail-fast, rather than return-none-fail-later
2024-10-14 16:15:45 +02:00
Klaas van Schelven
1ca7a1ecd9 Envelope-parser parameter rename for clarity
the error is about whether an EOF can happen _right after_ the
header is parsed.
2024-10-14 11:34:11 +02:00
Klaas van Schelven
782bb81b82 Envelope is not actually json; let's reflect that in the filename 2024-10-09 09:38:00 +02:00
Klaas van Schelven
cba2eb3584 Envelope-store logging: point to exact location for download 2024-10-09 09:36:17 +02:00
Klaas van Schelven
55e077e974 Document a finding 2024-10-08 22:09:26 +02:00
Klaas van Schelven
98776ebdfb Storing of envelopes: added as a debugging tool 2024-10-08 13:19:07 +02:00
Klaas van Schelven
0e48f346d1 Avoid cross-transaction pollution
in IMMEDIATE mode, project was passed from an (implicit) read transaction to
the immediate_atomic-wrapped code; this meant that it was possible to miscount
project.digested_event_count
2024-10-08 11:53:31 +02:00
Klaas van Schelven
f0006a63f5 raise_exception helper: tag should be string
> Tags are key/value string pairs that are both indexed and searchable.
2024-10-08 11:00:57 +02:00
Klaas van Schelven
5e5b53abed Remove a false comment
(groupings do imply issues, it's a FK)
2024-09-27 18:14:51 +02:00
Klaas van Schelven
c50ae7afe7 Pin sample to test
on github.com the glob evaluated such that the sample could not be
modified according to the test-setup
2024-09-19 15:01:07 +02:00
Klaas van Schelven
b2b63c9664 Use precompiled event_schema.py 2024-09-19 14:57:47 +02:00
Klaas van Schelven
8f0985cbe5 fastjsonschema: don't touch my data please!
I'm sure this can be useful, but since I validate before storing, this is just
a ReallyBadIdea(TM). For one, it makes it so that running with different settings
of VALIDATE_ON_DIGEST leads to different data in the DB
2024-09-19 13:46:13 +02:00
Klaas van Schelven
096d1f7d9a Add 'samples' tests as such explicitly 2024-09-19 13:10:13 +02:00
Klaas van Schelven
9fa5d97d04 VALIDATE_ON_DIGEST rename (is more precise) 2024-09-19 13:09:59 +02:00
Klaas van Schelven
ff37e8f40c Remove 'understandable_json_errors utils
turns out it already exists (best_match)
2024-09-19 12:39:06 +02:00
Klaas van Schelven
febbbc67c7 Use fastjsonschema for validation 2024-09-19 12:17:41 +02:00
Klaas van Schelven
d0eb6bea95 Validation: ignore the '_meta' property
we've observed that this is sent-in-practice. we don't want to
actually remove it from the stored data, so we remove it only
from the thing we validate (not the actual data)
2024-09-19 11:20:08 +02:00
Klaas van Schelven
fe9aba5c7d Add (optional) input validation using JSONSchema 2024-09-19 10:14:00 +02:00
Klaas van Schelven
618e4c43b2 Don't 'manually revert' on failure, this is what we have transactions for
and in fact doing a manual revert leads to a TransactionManagementError
2024-09-19 09:23:10 +02:00
Klaas van Schelven
9eed504474 test: raise exception when invalid data is present 2024-09-19 09:21:15 +02:00
Klaas van Schelven
f2a78fed9d Use the envelope's event_id when using the envelope endpoint
* As per the spec 'takes precendence'
* Also fixes the reported bug on Laravel, which apparently doesn't send event_id
  as part of the event payload.
* Fixes the envelope tests (they were doing nothing when I moved the
  data samples around recently)
* Adds a 'no event_id in data, but yes in envelope' test to that test.
* Adds handling to send_json such that we can send envelopes when the event_id
  is missing from the event data.
2024-09-18 11:36:47 +02:00
Klaas van Schelven
f4bbf0c386 Rewrite comment for understanding 2024-09-18 10:24:44 +02:00
Klaas van Schelven
8b7a8dbac5 Clarify a comment 2024-09-18 10:11:00 +02:00
Klaas van Schelven
1b6d17c947 Fix: when the first event of a new release is a regression, detect it
not detecting it was caused by incongruency between in-memory and serialized states of the data
2024-09-18 09:08:59 +02:00
Klaas van Schelven
c99702d046 Comment about why a patch function is used 2024-09-18 08:55:17 +02:00
Klaas van Schelven
c5465f2f8a Don't assume samples miss the 'timestamp' property
(we have fixed the samples accordingly)
2024-09-17 09:38:08 +02:00
Klaas van Schelven
937ffea15c Remove last remaining sample
we do this with the separate project now... the last remaining one
wasn't special enough to preserve
2024-09-16 14:39:44 +02:00
Klaas van Schelven
5f29a20765 send_json: print understandable json errors
at least: this works in the current set of circumstances
2024-09-16 14:20:21 +02:00
Klaas van Schelven
f1b75aab81 api.json.schema: put back in code, make test fail on invalidness and related fixes
This reverts course on 4201fbd778, and restores event.schema.json from that
commit.  In that commit we said: 'this is not used'. Not true: it's used in a
test, though this test used the validity check to silently skip.

In this commit:

1. Do _not_ just silently skip invalid samples. Since we have a way of properly
   validating, let's use that so that we know how useful the samples that we have
   actually are.

2. Deal with "_meta", a field that we sometimes see in the "private samples" (data
   that ultimately comes from running a somewhat recent python-sdk against my
   actual codebase). The need for this was exposed by [1]

3. Add a test for the up-to-date-ness of event.json.schema

4. remove special-cased attribute-checks in `is_valid`; `send_json` was, at the
   time, an opportunistic way to just get my hands on some sample data. the
   approach at validation reflected that: I just did some tests on the existence
   of certain attributes to determine which json files were even events. But in
   the end I did a full validation using an API schema, which kinda made the
   whole business useless. This commit cleans up the individual checks.
2024-09-16 11:28:05 +02:00
Klaas van Schelven
4201fbd778 remove vendored event.schema.json from codebase, document where it can be found in the future 2024-09-13 17:47:25 +02:00
Klaas van Schelven
497fbacb03 Remove event-samples from codebase
Properly sourced and licensed they are now at https://github.com/bugsink/event-samples
2024-09-13 11:11:12 +02:00
Klaas van Schelven
eec8d51491 Remove various non-TODOs
either already done, or more of a 'this is a way this code could potentially
evolve in the future' (but not a 'we must do this')
2024-09-13 10:05:22 +02:00
Klaas van Schelven
2e70197825 Add check_migrations command
this way, at least in the Docker setup, you'll get a meaningful error when you
try to start up a half-baked server
2024-09-09 15:31:14 +02:00
Klaas van Schelven
6bb853cd22 Comments about sqlite: take mysql into account too 2024-08-28 15:40:06 +02:00
Klaas van Schelven
129a8db421 Fix various flake8 errors 2024-08-21 09:31:05 +02:00
Klaas van Schelven
f7972cbec0 use datetime.timezone.utc
RemovedInDjango50Warning: The django.utils.timezone.utc alias is deprecated. Please update your code to use datetime.timezone.utc instead.
2024-08-21 09:01:20 +02:00