github atom36942/atom v34.0.0
Atom 34.0.0

49 minutes ago

Upgrade (projects must change):

  • Settings renamed. Startup refuses each old name in .env or config_extend.py and names the new one:

    Old New
    config_access_token_expires_sec, config_refresh_token_expires_sec config_access_token_expire_sec, config_refresh_token_expire_sec
    config_otp_expiry_sec, config_otp_max_attempt config_otp_expire_sec, config_otp_attempt_max
    config_blob_expire_sec_preview, config_blob_expire_sec_upload config_blob_preview_expire_sec (default now 3600, was 360000), config_blob_upload_expire_sec
    config_blob_limit_size_kb, config_blob_limit_upload config_blob_size_max_kb, config_blob_upload_max
    config_export_limit, config_batch_item_limit, config_query_runner_read_limit config_export_rows_max, config_batch_items_max, config_query_runner_rows_max
    config_sql_read_limit_max, config_sql_read_limit_default, config_sql_read_relation_fetch_limit_max config_sql_read_rows_max, config_sql_read_rows_default, config_sql_read_relation_rows_max
    config_cache_row_limit_config, _users_role, _users_deactivated, _users_deleted config_cache_rows_max_config, _users_role, _users_deactivated, _users_deleted

    The /info key export_limit keeps its name.

  • Settings loading: config.py no longer applies .env at import, so import config / from config import x gives code defaults only. Read settings with config = func_config_read() (every Atom script now does, .env keys included); from config import stays only for config_extend.py's # base, and script.check's rules step now fails on import config / from config import in any other *_extend/ file. Malformed JSON (or the wrong kind) for a list or dict setting, or a non-integer for an int setting, now stops startup. A new .env key whose value is t/f/y/n/true/yes/on loads as a boolean. A setting with no typed default (None, or a key only in .env) whose name has the word password, key, secret, token, dsn, url, username, user or number always stays text (a digit-only password was an int).

  • AI: the value claude is now anthropic (ai= in route bodies, config_ai_services, default ["gemini", "openai", "anthropic"]); an unknown name in config_ai_services stops startup, and an unknown ai is 400 (no fallback to OpenAI). Models come from the new config_ai_model_gemini, config_ai_model_openai, config_ai_model_anthropic.

  • Routes renamed (verb last; ids unchanged):

    Old New
    POST /private/send-email POST /private/email-send
    DELETE /my/message-delete-thread, GET /my/message-inbox, GET /my/message-thread DELETE /my/message-thread-delete, GET /my/message-inbox-read, GET /my/message-thread-read
    POST /my/object-create-mongodb POST /my/mongodb-object-create
    GET /my/api-usage, POST /my/blob-preview-urls, POST /admin/blob-preview-urls GET /my/api-usage-read, POST /my/blob-preview-url-read, POST /admin/blob-preview-url-read
    POST /admin/blob-container-ops, POST /admin/blob-container-sas POST /admin/blob-container-update, POST /admin/blob-container-sas-create (service=azure only)
    GET /public/converter-number GET /public/number-convert
    GET /admin/sync POST /admin/cache-sync
    GET /admin/postgres-info, -schema, -slow-queries GET /admin/postgres-info-read, -schema-read, -slow-queries-read
  • Methods and params:

    • /admin/object-delete and /my/object-delete are DELETE with query params: ?table=<t>&ids=1,2 (a comma list or a JSON list), mode and ownership_column as before. /my/blob-delete-all is DELETE.
    • ?col → ?column and ?agg_col → ?agg_column on every table-column-groupby and table-column-distinct route.
    • The OTP send routes read the body only, unknown params refused: /public/otp-send-email {service, email} (sender from the new config_otp_email_sender, 500 when unset), /public/otp-send-mobile {service, mobile}, /public/otp-send-mobile-sns-template {mobile} (template from the new config_sns_otp_template; startup checks its keys). Azure SMS sends from config_azure_sms_from_number only.
    • ?is_background and ?is_disable_cache are 400 unless the route opts in ("is_background": True / "is_disable_cache": True in config_api). Atom opts in object create/update and postgres-import (background) and the /private and /admin groupby/distinct routes (cache).
    • /admin/postgres-query-runner-write ships is_active: False, and AGENTS.md says to leave it off (write through PgWeb on localhost or a script).
  • Behaviour changes:

    • An unexpected exception type answers 500 "internal server error" (the real message goes to stderr and log_api.error); only a plain Exception or ValueError, or one with a status_code, stays 400 with its text. A value a column can't take (column 'x': invalid value: ...) and a CSV upload that is not UTF-8 stay 400. TimeoutError and ConnectionError are 503 "service unavailable".
    • func_postgres_update always returns the list of updated ids ([] when nothing matched), never "updated".
    • func_postgres_create: rows of one call with different keys raise "object keys mismatch"; a one-row create serialises like a bulk one (a string sent to a jsonb column is stored as a JSON string); a NULL array stays NULL. mode="flush" is gone: func_postgres_buffer_flush(...).
    • Filters: a OR b splits only when every part is a filter; commas and AND no longer split text or JSON contains values. group_values refuses null, and 1 and "1" are one group.
    • Schema sync compares type modifiers and defaults exactly, so a column whose length, precision or default differs gets ALTER at the next start. Index btree(lower(col)) is accepted; users gets idx_users_lower_email_role_btree and btree(last_active_at), idx_users_password_btree is dropped. Over-long CHECK/UNIQUE names are clamped and created at the next start.
    • config_is_cors_allow_credentials defaults to False. Pages get a Content-Security-Policy from the new config_page_csp, report-only while config_is_page_csp_report_only (default True). HSTS is sent when config_is_prod.
    • config_blob_container_allowed (new, default []): user upload, presigned-upload and /my preview routes answer 403 until a container is listed.
    • New users column password_changed_at (trigger users_password_changed_at): a refresh token issued more than 5 s before a password change gets 401 (5 s for the database's clock running ahead).
    • PgWeb answers only a localhost Host (open http://localhost:<port>/page/pgweb); a read-only script with transaction control, DO or CALL is refused; integers beyond ±(2^53−1) come as JSON strings.
    • /my/user-update with email or mobile null is 400. Public export, groupby and distinct are rate limited. Startup refuses OIDC link_email on a {tenantid} issuer without tenants. The OTP email is plain text on every provider.
    • Every Atom script reads settings through func_config_read() (so config_extend.py applies); the users-delete worker purges past retention hourly instead of every poll, and reads the owned tables again for each batch of tasks it claims.
    • Webhooks: delivery runs in up to four loops per worker, at most a quarter of the master pool, each sending on its job's own connection; it uses its own HTTP client, which never goes through an HTTP(S)_PROXY from the environment (the app needs direct outbound HTTPS). func_webhook_deliver_periodic_task takes no client_http; func_webhook_deliver(client_postgres=) is the job's connection. func_queue_postgres_job_take calls run(payload, conn): a project calling it directly adds the conn argument.
    • Kafka: group atom_<task> (was atom), starting at the oldest message: the first start may rerun kept messages.
    • ?is_background=true requests count against config_background_task_max on their own: Atom's internal background work no longer fills the cap.
  • Now sync (drop the await): func_token_encode, func_token_decode, func_postgres_column_regex_check (was func_regex_check), func_number_convert (was func_converter_number), func_middleware_active_check, func_middleware_auth_check, func_middleware_api_response_error.

  • Modules (only from function.<module> import is affected; app_state.func_* and from function import func_x work with the new names):

    Old New
    clients.py, checks.py, storage.py, messaging.py, queues.py, query_runners.py client.py, config_check.py, blob.py, message.py (+ email.py, otp.py), queue.py (+ producer.py, consumer.py), query_runner.py (+ postgres_query_runner.py, mssql.py, clickhouse.py)
    validation.py, data_import.py (removed) postgres_schema.py, auth.py, object.py; mongodb.py, postgres_import.py, request.py
    parts of auth.py, export.py, background.py, schedule.py, app.py, middleware.py, pgweb.py token.py, api_key.py, otp.py, user.py; postgres_export.py; postgres_connection.py, postgres_crud.py; script.py; admin.py, openapi.py, app_static.py, runtime.py; api.py (func_api_error), client.py (func_client_check); pgweb_common.py, pgweb_catalog.py, pgweb_rows.py, pgweb_query.py
    files/param_spec.py function/route_param_spec.py

    Rule: function/<f>.py and function/<f>_<part>.py define only func_<f>_* (a test enforces it).

  • Functions renamed (old → new; script.check names any call it no longer finds):

    • AI and app: func_anthropic_json → func_ai_anthropic_json; func_ai_claude_json, _gemini_json, _openai_json → func_ai_anthropic_sql_json, func_ai_gemini_sql_json, func_ai_openai_sql_json; func_ai_client_check → func_ai_client(app_state, ai); func_response_json → func_app_response_json; func_endpoint_json_wrap → func_app_endpoint_json_wrap; func_sentry_init → func_app_sentry_init; func_atom_version → func_app_atom_version_read; func_structure_init → func_app_structure_init; func_admin_sync → func_admin_cache_sync.
    • Auth: func_auth_user_login_fetch → func_auth_user_login_read; func_auth_check_user_active, _check_token_issued, _check_signup_role, _check_config → func_auth_user_active_check, func_auth_token_issued_check, func_auth_signup_role_check, func_auth_config_check; func_role_allowed_values → func_auth_role_allowed_values; func_token_check_secret_key → func_token_secret_key_check; func_mfa_token_encode / _decode → func_totp_mfa_token_encode / _decode; func_auth_login_finish → func_totp_login_finish; func_auth_login_totp → func_totp_login(app_state, client_postgres, mfa_token, code); func_auth_oidc_user → func_oidc_user_find_or_create; func_root_user_permissions / _sync → func_user_root_permissions / _sync.
    • Background: func_postgres_buffer_flush_periodic_task → func_background_buffer_flush_periodic_task; func_inmemory_cache_cleanup_periodic_task → func_background_cache_cleanup_periodic_task; func_async_tasks_cancel, func_app_tasks_start, func_app_tasks_stop → func_background_tasks_cancel, _start, _stop; func_table_retention_cleanup → func_postgres_retention_delete.
    • Startup checks: func_check → func_config_check; func_check_int → func_config_int_check; func_check_log_api_table, _database_config, _postgres_schema, _settings_removed, _runtime_config, _api_route, _api_config, _postgres_connections, _config_extend_alias, _config_extend_keeps_atom → func_config_log_api_table_check, func_config_database_check, func_config_postgres_schema_check, func_config_removed_check, func_config_runtime_check, func_config_api_route_check, func_config_api_check, func_config_postgres_connections_check, func_config_extend_alias_check, func_config_extend_atom_check.
    • Clients: func_client_s3, _sns, _ses → func_client_aws(service=); func_rabbitmq_close → func_client_rabbitmq_close; func_gemini_close → func_client_gemini_close.
    • Schema and objects: func_regex_check → func_postgres_column_regex_check; func_column_regex → func_postgres_column_regex_read; func_buffer_limit → func_postgres_buffer_limit_read; func_check_table_column_exists → func_postgres_table_column_check; func_config_api_names → func_postgres_api_name_dict; func_check_table_access, _table_not_users, _honeypot, _batch_limit → func_object_table_access_check, func_object_table_users_check, func_object_honeypot_check, func_object_batch_check; func_postgres_vector_columns → func_postgres_column_kinds(schema=).
    • Request, export, paging: func_query_bool_parse → func_request_bool_parse(value, default=None) ("ok" is no longer true; t/f/y/n are); func_attach_user_audit_fields → func_request_audit_fields_add; func_extract_request_object_list → func_request_object_list_read; func_api_file_to_chunks → func_request_csv_chunks_read; func_csv_cell, _row, _stream, _response → func_export_csv_cell, _row, _stream(batches=, columns=), _response; func_export_limit → func_export_limit_check; func_page_limit → func_postgres_page_limit_check; func_page_* → func_postgres_page_*.
    • Middleware: func_middleware_check_active, _auth, _user_status, _role, _permission, _ratelimiter, _ip_allow, _token_verify → func_middleware_active_check, _auth_check, _user_status_check, _role_check, _permission_check, _ratelimiter_check, _ip_allow_check, _token_verify_check; func_middleware_api_background(scope, request, config_background_task_max); func_middleware_api_cache takes is_disable_cache; func_middleware_security_headers takes is_prod.
    • PgWeb, queues, storage: func_pgweb_insert_row, _update_cell, _delete_row → func_pgweb_row_insert, func_pgweb_cell_update, func_pgweb_row_delete; func_producer → func_producer_send (and func_producer_<broker> → func_producer_send_<broker>); func_run_broker → func_consumer_broker_run; func_consumer_run → func_consumer_task_run; func_consumer_postgres → func_consumer_postgres_open; func_blob_container_ops → func_blob_container_update; func_blob_preview_urls_get → func_blob_preview_url_read; func_email_resend_post is removed.
    • Params: func_postgres_table_column_groupby_read(column=, agg_column=, config_sql_read_rows_max=, config_page_offset_max=) and _distinct_read(column=, ...) (were col=, agg_col=, app_state=); client_password_hasher is removed from the read functions; func_postgres_query_ai / func_clickhouse_query_ai take ai, client_ai, model; func_ai_sql_generate(ai, client, model, prompt, name); func_otp_send_mobile takes no sender; func_webhook_url_check returns the checked address; func_postgres_mark_read(app_state=, ...); func_message_socket_auth returns (user, exp); func_postgres_schema_init / _steps / _users_init take root_user_password= and client_password_hasher= (and no app_state for _steps / _tables_init). Inside function/ steps call each other directly, so a test patches the module attribute, not app_state.func_*.
  • config_api: the list form of user_check_role / _deactivated / _deleted is removed (startup says so).

  • Removed: script/postgres_ingestion.py; docs/faq.md and docs/audit.md (their facts moved to the docs that own each topic); Motor (client_mongodb is now pymongo's AsyncMongoClient, pinned as pymongo; a project importing motor adds it under # extend).

  • Pages: api.html's modals are <dialog> elements and its ids say what they hold (catalogSearch, runBtn, responseBox, wsEndpoint, headersSection, ...); its CSV is api_catalog.csv. pgweb.html's status bar is gone.

  • Kafka consumers join the group atom_<task> (one group per task, so a restart rebalances only that task). A new group starts from the oldest kept message: before upgrading a Kafka consumer, let its old group drain, or messages still kept may run again.

  • PgWeb health shows only the connected database; the new Server view (action: "server") holds the rest: overview and settings, the login's permissions (superuser, managed-cloud admin role, monitor), every database's counters and connections, long queries in any database, and the login roles.

Security:

  • Logins take the same time for unknown users and users without a password (dummy argon2 hash); the password is checked before the role, and each matching role is tried. Tokens carry iat.
  • OTP sends are limited per recipient (config_otp_send_per_hour_max, 5 an hour; 429); Fast2SMS sends its key in a header, never the URL; TOTP disable clears the secret, last step and recovery codes; the static OTP checks the identifier first.
  • The middleware strips the ASGI root path before looking up config_api, so a route served under --root-path keeps its auth.
  • PgWeb strips comments and literals before its read-only and unbounded-write checks, so a ; inside a string no longer splits a statement.
  • Webhook deliveries connect to the address that passed the public-address check, pinned in the connection itself (the URL, Host, TLS name and connection reuse keep the host name, so two hosts on one address never share a connection), and a host with any private address is refused.
  • On a public route ("auth": []) only an access token or an API key identifies the caller: a refresh or 2FA token no longer sets request.state.user (it stamped created_by_id on /public/object-create and keyed the rate limit).
  • The password hash never leaves a read: column=* expands without blocked, tsvector and vector columns.
  • S3 delete errors raise; a multi-file upload checks every file before uploading any; container SAS lasts 900 s (config_blob_container_sas_expire_sec).
  • Redis and AI clients have timeouts (5 s; AI 600 s and 2 retries); exports set idle_in_transaction_session_timeout; ?is_background requests are capped (config_background_task_max, 503 when full); the message socket checks deleted and deactivated users at connect.
  • script.check scans Atom's own tracked files for keys, tokens and URL passwords (new patterns: Azure account keys, Google API keys, GitHub tokens, Atom atk_ keys). CI runs with read-only permissions, actions pinned by commit SHA, and a newer push cancels an older pull-request run; every push to main runs to the end (its own concurrency group), and the release workflow has no group that could drop a pending release.

Performance (oha, 50 users, 1 worker, 33.0.1 → 34.0.0; full method in docs/benchmark.md):

  • /info 11,534 → 13,727 req/s (+19%); cached /public/object-read 10,496 → 12,176 (+16%); /private/object-read 3,136 → 3,438 (+10%); /my/object-read 2,855 → 3,247 (+14%); /my/object-create 4,478 → 5,011 (+12%).
  • CPU per request in-process: /health 40.2 → 32.0 µs, /info 51.5 → 37.1, cached read 59.3 → 42.4, private read 311 → 279, my read 338 → 296, my create 230 → 199.
  • in lists and OFFSET are bound (= ANY($n)), so asyncpg reuses 3 statements instead of one per list length and page (mixed paging: 1,510 → about 1,200 µs). Exports read in batches of 5,000 (1M rows: 13.9 → 11.1 s, byte-identical). Startup 0.70 → 0.64 s, idle memory 164 → 154 MB; import main 0.49 → 0.41 s.
  • sync.py reads every upstream file with one git cat-file --batch instead of one git process per file.
  • Each worker freezes what startup built (gc.freeze(), about 100,000 objects): full garbage collections no longer scan it, so their pause drops from 23–29 ms to under 0.5 ms (CPU per request unchanged). Monitor's memory view counts the frozen objects and lists the object types made since startup.
  • Passwords hash with the new config_password_hash_profile: owasp (default; argon2id 19 MiB, 2 passes, 1 lane) or strong (64 MiB, 3 passes, 4 lanes, the earlier default). A login or new password takes 19 MiB instead of 64 MiB and about a third less time (26 ms against 39 ms per verify here). Existing hashes keep their own cost and still verify; a password gets the profile when it is next set. Root's hash is rewritten once at the first start (root then logs in again); an unknown profile stops startup.
  • client_http makes its transport (CA bundle, proxy settings) on its first request: about 2 MB less per worker that never calls out. The OpenAPI spec walks each route's source once instead of twice (startup about 6 ms less). Importing main and starting loads no optional SDK (a test keeps it so).

Fixes:

  • Postgres queue workers survive database errors (backoff up to 30 s) and reopen a dropped LISTEN; Redis lock renewals and job finish failures are logged; a standby Redis consumer stops at the first SIGTERM; mark-as-read runs as a tracked background task.
  • CHECK/UNIQUE constraint names over 63 bytes were never created; CSV import reads a UTF-8 BOM; SQL wraps survive a trailing comment; interval, point and range columns bind correctly; bulk inserts keep plain json objects and bytes.
  • The root password is rewritten only when it changed, so restarts keep root's refresh tokens.
  • api.html: the Raw view no longer changes values, the light theme hover is readable, cURL export quotes every value, a pasted cURL cannot inject markup, Escape closes only the top dialog, and the fake 0.8 s loading overlay is gone. Copy cURL shows a typed Authorization value as it is sent, a pasted or added Authorization row is never replaced by the page's token, and --form-string fields paste back. Message keeps unsent drafts per conversation, a sent message never stays as a draft, and a message the socket did not confirm goes back in the box with a note that it may have been sent; Monitor ignores answers from a tab left behind; with reduced motion, the atom page draws frames only while something changes. PgWeb's Download asks where to save only once the server answered, so a refused or unconfirmed query leaves no empty file.
  • A test that sat after a __main__ guard (PgWeb filters) runs again; every test file lost its __main__ guard.
  • Tests: integration tests that boot the app share AppTestCase; Redis service tests moved to tests/integration/; source-text checks became behaviour checks (middleware order, the page route, user-create columns); new tests for the MSSQL retry, the message socket, the PgWeb route and the blob routes.
  • websockets and httpcore (webhook delivery) are pinned; Docker copies files already owned by the app user, compiles bytecode at build and leaves tests and CI out of the image; docker-compose.yml binds services to 127.0.0.1.

Docs:

  • Rewritten for an AI reader: one owner doc per fact, one plain template, no history; about 47% smaller (546 KB → 291 KB for docs/ and AGENTS.md). AGENTS.md has a full task → doc index and five more rules (no is_trusted=True with request data, no session state on pooled connections, never around the body limits, never re-enable a route Atom ships inactive, queued jobs safe to repeat).
  • Every doc was checked against the code; the new tests/test_docs.py keeps it so: links and anchors resolve, and every setting, function and route a doc names exists.

Don't miss a new atom release

NewReleases is sending notifications on new releases.