mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 16:58:36 +00:00
stop-reporting-builder-custom-code-errors
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
908ce9bdf3 |
fix(core): sanitize service sample data in user templates (#6548)
* fix(core): sanitize service sample data in exports and templates * fix(core): preserve workflow metadata in exported samples * test(database): preserve status in sanitized button samples |
||
|
|
2dd4defb3b |
feat(database): run a button click with external actions as a job (#6164)
* fix: keep every button action card in place after a save A retyped action can keep its id, and an action created by an earlier save still carries its client id, so the refetched list must keep the client id of every buffered action rather than only the created ones. * feat(jobs): let a job type choose its Celery queue * test: assert the job enqueue through apply_async * refactor(database): expose the button click pre-checks on the service * refactor(database): share the button click payload and outcome mapping * feat(database): run a button click with external actions as a job * fix(database): map click races on the job and assert the audit entry * feat(database): answer a click with external actions with a job The request returns 202 and the job runs the sequence, so a slow endpoint holds a Celery worker instead of a WSGI one. * fix(database): give a capped click its slots back and cover the denied job * refactor(database): raise a plain exception for a denied click job * chore: consume the button_dispatch queue on the default worker * chore: add the button_dispatch queue to the Zed worker launch config * feat(database): wait on the job of an accepted button click * fix(database): stop waiting on a button click job after a deadline * test(e2e): a slow endpoint no longer blocks the grid during a click * test(e2e): name the second-button test for what a single worker can prove * test: assert the airtable import job enqueue through apply_async * chore: changelog for the button dispatch job * fix(database): keep the clicker's IP and session on a button click job The audit log and analytics read both from the user, which the job only restores through these mixins. * fix(database): fail a button click job whose field or table was trashed * fix(database): serialize the busy check of a click with its job creation Two racing requests could both see the cell free and each start a job, so a single worker sent every request twice. Also drops the budget bookkeeping from the inline path, which no longer reaches outside Baserow. * test: assert a refused dispatch check records no audit entry * docs: say a button click job shares the default worker with realtime updates Also adds the automation_workflow and button_dispatch queues to the example supervisor config. * fix(database): check a button click job once more at the deadline The job store stops polling before the deadline, so a job that finished unseen was reported as still running. * test: cover an accepted click in the row modal and on a card * refactor(database): ask the service whether a cell has a click in flight The view queried the job table itself; the check belongs beside the other dispatch rules in the service. * fix(database): run only the action list a click was accepted with The request checks and charges one list; the job re-read the field's current one, so an action added while the job waited ran unchecked and an added external one sent without a rate-limit slot. * fix(database): keep queued button clicks sane across crashes, retypes and trash A dead worker's job no longer blocks its cell until cleanup, a retype no longer deletes a queued job, and a trashed database refuses the click. Core permission refusals use the API's wording. The cell lock is shared and the unused refund plumbing is gone. * fix(database): stop a queued button click from sending twice or unchecked A late or replica-blind click no longer repeats its requests, a retype to external is caught, and a quota refusal answers in the request. Slots come back when no job row was written, and the stored answer is safe for jsonb. * fix: keep polling a button click job after one failed poll A click waits on the job store, which stopped for good after a single failed poll. A settled click's job is dropped so the store stops polling it. * fix(database): stop a cancelled button click between actions The owner can cancel a running job, and later actions still ran. The last job check at the deadline is bounded too, so a hung request cannot keep the button spinning. * test: cover a job's answer reaching Open URL and a click edited while queued * fix(database): let a click job finish when its button is retyped mid-run The worker's save wrote the old field id back and failed. Timeouts and unmapped failures no longer name the job type, and a job that is already final leaves the store. * fix(database): run button click jobs on the export queue Review feedback: the celery queue is for fast tasks, and a new queue needs every self-hosted worker changed. Also strips lone surrogates from the stored answer, moves the enqueue rules into the service and drops the unused websocket id. * fix(database): drop a waiting button click on logout or table switch A job can end minutes after the click, when its toast or Open URL no longer belongs to the page. * chore: drop the changelog entry for #6134 The button field has not shipped yet, so there is no fix to announce. * fix(database): point a click job at the base field A retype deletes the button row, so a job pointing at it had to be nulled first, and a click landing meanwhile failed the retype. * fix(database): keep a button spinning for its job after a reload The spinner only knew about clicks made in this page, so a reload dropped it while the job ran and a second click got the 409 toast. * fix(database): ignore a late job_started for a settled button click On a single worker the broadcast reaches the clicking tab after the job ended, and its started copy spun the button again until the next poll. * docs(database): correct the dispatch signal and e2e comments The signal's first send for a job click happens before the enqueue lock. |
||
|
|
d0aef1e178 |
Button field: bound one HTTP action by its timeout (#6104)
* fix: stop a trickled response body from outliving its deadline iter_content blocks inside urllib3 until a whole chunk arrives, so the deadline check never ran against a server sending a byte at a time. * feat: send an HTTP request under one deadline across redirects Requests gives every hop a fresh timeout and reads redirect bodies unbounded, so a redirecting endpoint could outlive the button's row lock. * fix: hang up an HTTP request whose headers outlast its deadline The per-hop timeout only bounds a single socket read, so a server trickling out a status line or headers could hold the connection open long past the deadline. * fix: hang up a connection that opens after the HTTP deadline The watchdog only shut down sockets already open when it fired, so a connection still resolving DNS or finishing a TLS handshake at that moment kept trickling headers past the deadline. * fix: bound the HTTP request action by one deadline Its lock budget now covers the worst case that deadline allows. * fix: send a button's external action outside a database transaction On a click the dispatch savepoint was the only transaction, held open for the whole network wait. * test: add a barrier stub e2e tests can hold requests on * test: hold the button concurrency e2e requests on a barrier They now wait until the backend's request has arrived instead of relying on a slow endpoint, and F2 proves both locks were held at once. * fix: report a TLS error while reading a response body as one * docs: say what the dispatch savepoint and the HTTP watchdog cover * test: pin the barrier stub image by digest * test: run the held-request e2e tests one after the other * fix: keep a redirect's body when it is the final response The redirect hook already read it, and reading again overwrote it with nothing. * fix: report a cut-off compressed body as a timeout A body read until close could not be hung up on, and a cut-off one surfaced as a decode error. * refactor: run HTTP deadlines on one watchdog thread A thread and eight classes per request, and a response held in a reference cycle, cost more than one shared watchdog. * fix: send the Slack action under the request deadline Its per-socket timeout let a slow endpoint hold the click past the row lock. * test: give the HTTP deadline tests room on a busy runner One second of margin was too little under -n auto; a regression still takes ten. * refactor: let the dispatch context choose to send outside the savepoint Sending outside the savepoint was inferred from in_atomic_block, which pytest-django's db fixture always reports True for, so only the transaction=True tests ever covered production behaviour. The dispatch context now says explicitly whether its caller sends outside a transaction of its own. * refactor: derive a database action's is_external from its service The action's own flag could drift from the service type it dispatches through, so it now reads that service type's flag instead of keeping a second copy. * refactor: remove the unused HTTP request function getter The HTTP and Slack services now send through send_http_request, so nothing calls get_http_request_function any more. * test: give each held-request e2e run its own barrier keys The chrome and firefox projects both run this file by default and were sharing the fixed "slow"/"slow-two" barrier keys and its reset, so a parallel run of one project could release or wipe the other's hold. * fix: keep the HTTP deadline watchdog running when a hang-up fails An unguarded hang_up() killing the one watchdog thread would silently stop deadline enforcement for the whole process. * docs: correct the dispatch flag and test comments The old wording pointed at the wrong transaction and repeated or narrated stale reasoning that no longer matches the code. * fix: keep a failed hang-up from logging the request's address Loguru prints frame locals beside a traceback, and a watched socket's repr names its peer. * test: stop the failing hang-up test racing its own deadline A send slower than its 0.3 s deadline on a busy runner timed out before the failing hang-up was in place. * fix: give every connect attempt only the time left to the deadline urllib3 and advocate try each resolved address with the timeout the hop started with, so four addresses that never answer took four timeouts. * test: start the barrier keys over before each held-request test A released key stays released, so the second test in a worker was answered at once and never held its lock. * fix: watch a proxied request's connections under its deadline Requests keeps a pool manager per proxy apart from the adapter's own, so its sockets were never watched and a trickling proxy held a request past its deadline. * docs: say what sending outside the savepoint relies on * fix: keep two HTTP timeouts outside a click and drop the audit hook Builder and automation keep the budget they had until #6117 settles theirs. send_http_request now reads the body itself, and connect attempts are bounded in the connect loops, so no process-wide audit hook is needed. |
||
|
|
886925500f |
feat[4a/6] Button field: send an HTTP request (#5968)
* feat: let a button field send an HTTP request A button can now call an endpoint when it is clicked, and the actions after it can read what came back. The request runs as part of the click, in the order the actions are listed, and a failure stops the ones behind it without rolling back what already ran. What an endpoint answers with has no shape until it has answered once, so a click by someone who may configure the field remembers the response and the editor builds the data explorer from it. Only a successful answer is kept, it is capped in size, and it never travels in an export, a snapshot or a duplicate. Because a click now makes this installation send a request, it is rate limited per user and per workspace, and only clicks that reach outside count. The address guard that stops a request reaching Baserow's own network applies here too, and a failure is reported by position without naming the URL it could not reach. * feat: say what a button's request has answered, and what it has not The data explorer only offers an HTTP action's body once a click has answered, and until then nothing said why. The action's form now carries the same block the builder uses: what the last click remembered, or a note explaining that a click is what captures it. The note also says the button's other actions run on that click, which a preview elsewhere in Baserow has no reason to warn about. * fix: stop a refused click from spending the budget, and sharpen what it is told A click refused by a permission check kept the slots it reserved, so a member who may not dispatch could spend the whole workspace's budget on refusals and lock out the members who may. The lock is now sized from what the click may wait for. The setting was a fixed two minutes while a button can chain requests that are each allowed to wait that long on their own, so the lock expired mid sequence on exactly the buttons it was there to protect. An external failure no longer hides a message about the values the action was given, such as a body that is not JSON. Only a message naming the address is withheld, since that is the part written for whoever configured the button rather than whoever clicked it. A result is returned to the browser only when a client action can read it. An answer from outside Baserow carries whatever the endpoint sent back, response headers included, and a clicker with nothing to run has no use for it. Also gives the remembered answer its own savepoint, so a value the column refuses cannot leave an enclosing transaction unusable, logs why it was refused, declares the 429 the endpoint can now return, and matches a duplicated field by the name the job gives it. * fix: charge a click for what it really sent, and stop leaking what it was told Answers the review on the button field's external actions. A click now takes one rate limit slot per action that reaches outside Baserow, rather than one per click, and gives back whatever it did not spend. The action list is read once and used for the budget, the permission checks and the run, so the three cannot disagree. A failure that names an address no longer reaches the log with the URL and request headers attached, only the ids and the exception class. A result the browser has no client action to hand it to is not sent at all. The classification is now a list of the failures that can name an address, so everything else keeps its own message and a malformed body says so. An HTTP response is read in chunks against a ceiling instead of being buffered whole, so an endpoint cannot decide how much memory a worker spends. A captured answer is dropped when a request-shaping value changes, and is not rewritten when it has not changed. A nested service type that disagrees with the action is refused rather than silently dropped. In the editor, the payload viewer shows what the explorer's paths name, a newly added request already offers its status code, raw body and headers, and reopening a field re-reads what a click captured. Docs get the four button field variables, the corrected lock TTL, and an ADR section that says secrets reach an export with external actions rather than external integrations. Claude-Session: https://claude.ai/code/session_01EwBqQJNK8seaAC5j8ppjF4 * fix: leave a button's API key out of an export An HTTP request action has no integration, so its key lives in the service's own headers and query parameters. Both were exported in clear text, and travelled wherever the export went: snapshots, workspace exports, templates. `CoreHTTPRequestServiceType` now names them sensitive, and the export config reaches them. `FieldType.export_serialized` takes it, the application export passes it, and the button field hands it to its actions, which blank whatever the backing service calls sensitive. The paths that stay inside the installation, duplicating a field and restoring a snapshot, pass no config and keep the key, so a copy still works. Which header holds the key is not knowable, so the whole list goes rather than a guess at the secret one, and the import reads a stripped list as none of them. Claude-Session: https://claude.ai/code/session_01EwBqQJNK8seaAC5j8ppjF4 * test: guard the editor's explorer without leaving the page Every other test here navigates or reloads between building a button and reading what it captured, which fetches from the backend again and hides what the editor was holding. This one stays on one page: it adds an HTTP action and a dependent action through the editor, checks the later one is already offered the status code and raw body before either has been saved, then saves, clicks, and reopens the field to find the answer the click just got. Without the baseline schema the request has no node at all until the field is saved and reopened. Without the re-read on reopen the captured body stays missing until the page is reloaded. * fix: hang up on a response that never stops arriving Requests treats a scalar timeout as inactivity, so it starts again on every byte. A server sending one every few seconds held the connection open for as long as it liked, and the click outlived the lock sized to `2 x sum(timeouts)`. Once Redis expired that lock a second click could start and repeat actions that are not reversible, which is the case the lock exists for. The body is now read against a wall-clock deadline as well as the size ceiling, both inside the streaming loop, and a deadline reached is reported the same way as any other timeout. The connect and header phases still use Requests' own inactivity timeout. Closing those needs a renewable lock, which is left as a follow-up. * feat: say why a click captured nothing A click that answered 404, timed out, or came back larger than the sample data ceiling captured nothing and said so nowhere. The note asking for a click stayed exactly as it was, so there was no way to tell the click had already happened. The action type now says why a result describes no shape rather than only that it does not, and the reason is stored under the `_error` sentinel the builder and automation already use. The editor shows it in place of the note, through the viewer's existing error state. Only written when there is nothing to lose: a shape an earlier click learned outlives an explanation of the latest one, and every action pointing at that shape would break with it. The reason names the status code but never the address, which is for whoever configured the button rather than whoever clicked it. `generate_schema` now skips a stored failure. It is truthy, so the body would otherwise come back as an empty object rather than being left out. * fix: close the holes a review found in the button field's external actions Seven of these are regressions from the earlier review fixes on this branch. An external action no longer logs its own exception, whatever type it is. The previous rule keyed on the failure, but loguru prints the frame locals beside the traceback and the frame that resolved the formulas holds the URL and every resolved header, so a malformed body or an oversized answer still wrote the key to the log. A click no longer asks for more rate limit slots than the limit could ever hold. Slots are taken one at a time, so a button carrying more requests than the budget was refused the slot past the limit and could never be clicked at all, however long anybody waited. Past that point the limit is back to counting clicks. A click is charged only for requests that were really sent. The callback fired before the formulas were resolved, so a header naming a deleted field, or a body that is not valid JSON, spent the budget without reaching anything. Reading the response no longer skips its ceiling when the ceiling is switched off. It returned before consuming the body, so a truncated or corrupt answer surfaced later as a 500 rather than a handled failure, and the drip deadline was never armed. An export keeps the keys of what it strips and blanks only the values, so an imported button says what has to be entered again instead of quietly sending a request without its `Content-Type`. Form data and the body are stripped too, not only headers and query params. The AI formula prompt no longer sends a button's headers to the provider. It serialized every field with no export config, and reading a formula field needs far less permission than configuring a button does. The editor's re-read on reopen takes only what a click captured, matched by id, so an unsaved action edit survives it. Also: loguru ignores `exc_info`, so two handlers were swallowing their tracebacks; the sample data cap measured escaped JSON, which refused a Japanese answer at half the documented size; the unchanged-answer check compared whole values, and `Date` alone moves every second, so nearly every click rewrote the blob it was meant to skip; and an e2e test found the duplicated field by an index that a new column had shifted. * fix: charge, log and explain a click the way the last review asked Four follow-ups from the review of the external actions. A button carrying more requests than a rate limit could ever hold is now refused rather than reserved for what fits: capping the reservation still sent every request, so the limit was paying for a burst of any size. An address Advocate refuses is told apart from a connection that failed, so a click that never sent anything gives its slot back. The HTTP service no longer logs its own unknown failures with the traceback. The frame holds the URL, the resolved headers and the body, and so does the one that could not keep an answer, so both log the class of the failure and the ids only. A reason left by an earlier failed click is replaced by the next one: a 404 followed by a timeout kept describing the 404. A shape an earlier click learned is still never overwritten. The e2e concurrency test waits for the first request to finish before closing the competing context. |