-
Notifications
You must be signed in to change notification settings - Fork 1
feat(hosting): expose deployment logs #4
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,8 @@ use async_trait::async_trait; | |
|
|
||
| use crate::Result; | ||
| use crate::host::types::{ | ||
| AnalyticsQuery, AnalyticsSummary, Database, DatabaseSpec, DeployRequest, Deployment, Domain, | ||
| EnvVar, EnvVarRecord, Site, SiteSpec, | ||
| AnalyticsQuery, AnalyticsSummary, Database, DatabaseSpec, DeployRequest, Deployment, | ||
| DeploymentLog, Domain, EnvVar, EnvVarRecord, Site, SiteSpec, | ||
| }; | ||
| use crate::providers::ProviderKind; | ||
|
|
||
|
|
@@ -134,6 +134,14 @@ pub trait Host: Send + Sync + std::fmt::Debug { | |
| /// Returns a provider error. | ||
| async fn list_deployments(&self, site: &str, limit: u32) -> Result<Vec<Deployment>>; | ||
|
|
||
| /// Lists the build and runtime events a deployment recorded, oldest first. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns a provider error, including [`Error::NotFound`](crate::Error::NotFound) | ||
| /// for an unknown deployment identifier. | ||
| async fn deployment_logs(&self, id: &str) -> Result<Vec<DeploymentLog>>; | ||
|
Comment on lines
+137
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This adds a required method and a new provider-independent type to the public AGENTS.md reference: AGENTS.md:L207-L211 Useful? React with 👍 / 👎. |
||
|
|
||
| /// Points the site's production traffic at an existing deployment. | ||
| /// | ||
| /// This is both the promote and the rollback: a rollback is a promote of an | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,11 @@ | |
| //! disagree about their names — `uid` against `id`, `state` against `readyState`. | ||
|
|
||
| use serde::{Deserialize, Serialize}; | ||
| use serde_json::Value; | ||
|
|
||
| use crate::host::types::{ | ||
| Database, DatabaseKind, Deployment, DeploymentStatus, DeploymentTarget, Domain, EnvVarRecord, | ||
| Framework, Site, | ||
| Database, DatabaseKind, Deployment, DeploymentLog, DeploymentStatus, DeploymentTarget, Domain, | ||
| EnvVarRecord, Framework, Site, | ||
| }; | ||
|
|
||
| /// The body of `POST /v11/projects`. | ||
|
|
@@ -140,6 +141,41 @@ pub(super) struct Deployments { | |
| pub(super) deployments: Vec<DeploymentBody>, | ||
| } | ||
|
|
||
| /// The envelope returned by `GET /v3/deployments/{id}/events`. | ||
| #[derive(Deserialize)] | ||
| pub(super) struct DeploymentEvents { | ||
| #[serde(default)] | ||
| pub(super) events: Vec<DeploymentEvent>, | ||
| } | ||
|
Comment on lines
+144
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🌐 Web query:
💡 Result: According to the Vercel REST API reference, the Citations:
🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- candidate files ---'
git ls-files 'src/providers/vercel/*'
printf '%s\n' '--- relevant symbols and endpoint calls ---'
rg -n -C 6 'DeploymentEvents|DeploymentEvent|into_log|/v3/deployments|events' src/providers/vercel
printf '%s\n' '--- wire.rs outline ---'
ast-grep outline src/providers/vercel/wire.rs
printf '%s\n' '--- wire.rs relevant section ---'
sed -n '120,195p' src/providers/vercel/wire.rs
printf '%s\n' '--- mod.rs relevant section ---'
rg -n -C 12 'DeploymentEvents|deployments/.+events|events' src/providers/vercel/mod.rs
printf '%s\n' '--- test.rs relevant section ---'
rg -n -C 15 'DeploymentEvents|events|deployment.*event|event' src/providers/vercel/test.rsRepository: tinyhumansai/tinyhosts Length of output: 14224 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- JSON decoding path ---'
sed -n '1,220p' src/providers/vercel/http.rs
rg -n -C 8 'get_json|from_slice|from_str|serde_json' src/providers/vercel src
printf '%s\n' '--- all deployment-event references ---'
rg -n -C 8 'deployment_events_preserve|deployment_logs|DeploymentEvent|DeploymentEvents' .
printf '%s\n' '--- dependency and tool availability ---'
rg -n -C 3 'serde_json|serde' Cargo.toml Cargo.lock
command -v rustc || true
command -v cargo || true
printf '%s\n' '--- deterministic JSON-shape probe ---'
python3 - <<'PY'
import json
samples = {
"object envelope": {"events": []},
"top-level empty array": [],
"top-level null": None,
"array with null item": [None],
}
for name, value in samples.items():
encoded = json.dumps(value, separators=(",", ":"))
parsed = json.loads(encoded)
print(f"{name}: {encoded}; top-level={type(parsed).__name__}; "
f"item_types={[type(x).__name__ for x in parsed] if isinstance(parsed, list) else 'n/a'}")
PYRepository: tinyhumansai/tinyhosts Length of output: 50378 🏁 Script executed: #!/bin/bash
set -eu
log=/tmp/coderabbit-shell-logs/shell-output-7KfQLv
printf '%s\n' '--- dependency/tool tail ---'
rg -n -C 3 'serde_json|serde|rustc|cargo|top-level|envelope|array with null' "$log" | tail -80
printf '%s\n' '--- focused deployment test ---'
sed -n '496,525p' src/providers/vercel/test.rs
printf '%s\n' '--- focused deployment implementation ---'
sed -n '430,448p' src/providers/vercel/mod.rs
printf '%s\n' '--- focused wire model ---'
sed -n '138,173p' src/providers/vercel/wire.rs
printf '%s\n' '--- standalone shape/type compatibility probe ---'
python3 - <<'PY'
import json
# This models the JSON token compatibility relevant to serde:
# an object struct accepts only an object, Vec<T> accepts only an array,
# Option<T> accepts null or the representation accepted by T, and
# Vec<Option<T>> additionally accepts null array elements.
samples = [
("envelope", {"events": []}),
("events array", [{"created": 2, "type": "stdout", "payload": "ok"}]),
("top-level null", None),
("nullable event item", [None]),
]
for name, value in samples:
token = json.dumps(value, separators=(",", ":"))
top = "null" if value is None else "object" if isinstance(value, dict) else "array"
item = (
"n/a"
if not isinstance(value, list)
else ["null" if x is None else "object" for x in value]
)
print(f"{name}: json={token}; top_level={top}; items={item}")
PYRepository: tinyhumansai/tinyhosts Length of output: 5930 Decode deployment events as a nullable top-level array.
🤖 Prompt for AI Agents
Comment on lines
+146
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Vercel's Useful? React with 👍 / 👎. |
||
|
|
||
| /// One Vercel deployment event. | ||
| #[derive(Deserialize)] | ||
| pub(super) struct DeploymentEvent { | ||
| #[serde(default)] | ||
| pub(super) created: Option<u64>, | ||
| #[serde(rename = "type")] | ||
| pub(super) kind: String, | ||
| #[serde(default)] | ||
| pub(super) payload: Option<Value>, | ||
| } | ||
|
|
||
| impl DeploymentEvent { | ||
| /// Preserves a non-string payload as JSON rather than silently losing it. | ||
| pub(super) fn into_log(self) -> DeploymentLog { | ||
| let message = match self.payload { | ||
| Some(Value::String(message)) => message, | ||
| Some(payload) => payload.to_string(), | ||
| None => String::new(), | ||
| }; | ||
|
|
||
| DeploymentLog { | ||
| created_at_ms: self.created, | ||
| kind: self.kind, | ||
| message, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// One entry of the `POST /v10/projects/{id}/env` array body. | ||
| #[derive(Serialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For deployments that have begun serving requests, this contract promises runtime events, but
/v3/deployments/{id}/eventssupplies deployment/build events rather than serverless or edge runtime invocation logs. Callers therefore receive no post-deployment runtime output despite the public API and RPC documentation saying they will; either integrate Vercel's runtime-log API or narrow this contract to build events.Useful? React with 👍 / 👎.