Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ jobs:
- uses: EmbarkStudios/cargo-deny-action@91bf2b620e09e18d6eb78b92e7861937469acedb # v2
with:
command: check
arguments: --config deny.toml
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "accelbyte-ags-cli"
version = "0.1.0"
version = "0.1.0-rc1"
edition = "2021"
description = "Unified CLI for AccelByte Gaming Services"
license = "MIT"
Expand Down
4 changes: 1 addition & 3 deletions src/invocation/commands/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,7 @@ async fn await_callback(

let spinner_message = |remaining: u64| -> String {
if remaining == 0 {
format!(
"Listening on http://127.0.0.1:{callback_port} for browser callback... waiting"
)
format!("Listening on http://127.0.0.1:{callback_port} for browser callback... waiting")
} else {
format!(
"Listening on http://127.0.0.1:{callback_port} for browser callback... {remaining}s remaining"
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/auth/locking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn lock_from_path(path: &std::path::Path) -> Result<FileLock, RuntimeError> {
message: e.to_string(),
details: None,
hint: None,
trace: None,
trace: None,
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/config/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ pub(crate) fn internal_error(message: impl Into<String>) -> RuntimeError {
message: message.into(),
details: None,
hint: None,
trace: None,
trace: None,
}
}
4 changes: 2 additions & 2 deletions src/runtime/config/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ pub fn validate_profile_name(name: &str) -> Result<String, RuntimeError> {
message: "Profile name cannot be empty.".to_string(),
details: None,
hint: Some("Use a name like 'default', 'staging', or 'prod-us'.".to_string()),
trace: None,
trace: None,
});
}
let valid = normalised
Expand Down Expand Up @@ -452,7 +452,7 @@ pub fn resolve_profile_name(flag: Option<&str>) -> Result<String, RuntimeError>
"Run 'ags profile create <name>' and 'ags profile use <name>' to get started."
.to_string(),
),
trace: None,
trace: None,
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/dispatch/error_codes/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ pub(super) fn lookup(error_code: i64) -> Option<ErrorMapping> {
suggestion: Some("Verify the entitlement ID and retry."),
tip: None,
}),
31142 | 31143 | 31144 => Some(ErrorMapping {
31142..=31144 => Some(ErrorMapping {
message: "Entitlement not found.",
reason: Some("No entitlement matches the supplied lookup key."),
suggestion: Some("Verify the appId, SKU, or itemId and retry."),
Expand Down Expand Up @@ -1057,7 +1057,7 @@ pub(super) fn lookup(error_code: i64) -> Option<ErrorMapping> {
suggestion: Some("Verify the transaction ID and product ID."),
tip: None,
}),
39142 | 39143 | 39144 | 39145 | 39146 | 39147 | 39148 => Some(ErrorMapping {
39142..=39148 => Some(ErrorMapping {
message: "Platform IAP config not found in this namespace.",
reason: Some("The platform's IAP configuration is missing."),
suggestion: Some("Configure the platform IAP for this namespace."),
Expand Down
11 changes: 5 additions & 6 deletions src/runtime/dispatch/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,15 @@ pub(crate) async fn execute_operation(
// the raw body as `errorMessage` so classify still produces the right
// status-based message + suggestion (instead of falling back to a
// bare "HTTP N error." with an empty Detail line).
let error_object = serde_json::from_str::<serde_json::Value>(&body_text).unwrap_or_else(
|_| {
let error_object =
serde_json::from_str::<serde_json::Value>(&body_text).unwrap_or_else(|_| {
let cleaned = strip_terminal_control_sequences(&body_text);
if cleaned.is_empty() {
serde_json::Value::Null
} else {
serde_json::json!({ "errorMessage": cleaned })
}
},
);
});
let mut runtime_error = crate::runtime::dispatch::classify::classify_to_runtime_error(
status,
&error_object,
Expand Down Expand Up @@ -305,14 +304,14 @@ fn map_cli_error_to_runtime_error(err: crate::errors::CliError) -> RuntimeError
message,
details: None,
hint: None,
trace: None,
trace: None,
},
other => RuntimeError {
kind: RuntimeErrorKind::Internal,
message: other.to_string(),
details: None,
hint: None,
trace: None,
trace: None,
},
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/dispatch/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub(crate) async fn read_response_body(
message: "Response body is not valid UTF-8.".to_string(),
details: None,
hint: None,
trace: None,
trace: None,
})
}

Expand All @@ -193,8 +193,7 @@ pub(crate) async fn read_response_body_tagged(
// no meaningful media type. Classifying them as Binary would route them
// through the binary-output path and suppress the success summary and the
// verbose request/response trace.
let is_text_body =
bytes.is_empty() || status >= 400 || is_text_content_type(&content_type);
let is_text_body = bytes.is_empty() || status >= 400 || is_text_content_type(&content_type);

if is_text_body {
return match String::from_utf8(bytes) {
Expand Down
121 changes: 58 additions & 63 deletions src/runtime/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,71 +173,66 @@ impl ExecutionContext {
access_token_source,
access_token_expiry,
access_token_warnings,
) =
if input.is_dry_run {
let (url, source) = auth::credentials::resolve_base_url(&profile)
.map(|(url, source)| {
let mapped = match source {
auth::credentials::CredentialSource::Environment => {
BaseUrlSource::Environment
}
auth::credentials::CredentialSource::Configuration => {
BaseUrlSource::Configuration
}
auth::credentials::CredentialSource::Keystore => {
BaseUrlSource::Keystore
}
};
(url, mapped)
})
.unwrap_or(("https://<base-url>".to_string(), BaseUrlSource::Default));
(
url,
source,
"dry-run-token".to_string(),
AccessTokenSource::DryRun,
None,
vec![],
)
} else {
let (url, source) = auth::credentials::resolve_base_url(&profile)
.map(|(url, source)| {
let mapped = match source {
auth::credentials::CredentialSource::Environment => {
BaseUrlSource::Environment
}
auth::credentials::CredentialSource::Configuration => {
BaseUrlSource::Configuration
}
auth::credentials::CredentialSource::Keystore => {
BaseUrlSource::Keystore
}
};
(url, mapped)
})
.ok_or_else(|| RuntimeError::from(auth::errors::AuthError::BaseUrlMissing))?;
) = if input.is_dry_run {
let (url, source) = auth::credentials::resolve_base_url(&profile)
.map(|(url, source)| {
let mapped = match source {
auth::credentials::CredentialSource::Environment => {
BaseUrlSource::Environment
}
auth::credentials::CredentialSource::Configuration => {
BaseUrlSource::Configuration
}
auth::credentials::CredentialSource::Keystore => BaseUrlSource::Keystore,
};
(url, mapped)
})
.unwrap_or(("https://<base-url>".to_string(), BaseUrlSource::Default));
(
url,
source,
"dry-run-token".to_string(),
AccessTokenSource::DryRun,
None,
vec![],
)
} else {
let (url, source) = auth::credentials::resolve_base_url(&profile)
.map(|(url, source)| {
let mapped = match source {
auth::credentials::CredentialSource::Environment => {
BaseUrlSource::Environment
}
auth::credentials::CredentialSource::Configuration => {
BaseUrlSource::Configuration
}
auth::credentials::CredentialSource::Keystore => BaseUrlSource::Keystore,
};
(url, mapped)
})
.ok_or_else(|| RuntimeError::from(auth::errors::AuthError::BaseUrlMissing))?;

let resolution = auth::session::resolve_access_token(http, &profile).await?;
let token_source = match resolution.source {
auth::session::TokenSource::Environment => AccessTokenSource::Environment,
auth::session::TokenSource::Stored => AccessTokenSource::Stored,
auth::session::TokenSource::Refreshed => AccessTokenSource::Refreshed,
auth::session::TokenSource::ClientCredentials => {
AccessTokenSource::ClientCredentials
}
};
let expiry = resolution
.expires_in_secs
.map(crate::support::format_duration);
(
url,
source,
resolution.token,
token_source,
expiry,
resolution.warnings,
)
let resolution = auth::session::resolve_access_token(http, &profile).await?;
let token_source = match resolution.source {
auth::session::TokenSource::Environment => AccessTokenSource::Environment,
auth::session::TokenSource::Stored => AccessTokenSource::Stored,
auth::session::TokenSource::Refreshed => AccessTokenSource::Refreshed,
auth::session::TokenSource::ClientCredentials => {
AccessTokenSource::ClientCredentials
}
};
let expiry = resolution
.expires_in_secs
.map(crate::support::format_duration);
(
url,
source,
resolution.token,
token_source,
expiry,
resolution.warnings,
)
};

// Namespace resolution: input override -> env -> profile config.
// Namespace is optional — missing namespace is not an error at this layer.
Expand Down
8 changes: 4 additions & 4 deletions src/support/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub fn encode_url_path_segment(value: &str, param_name: &str) -> Result<String,
message: "Invalid parameter value: path traversal ('..') is not allowed.".to_string(),
details: None,
hint: None,
trace: None,
trace: None,
});
}
if value.contains('?') {
Expand All @@ -233,7 +233,7 @@ pub fn encode_url_path_segment(value: &str, param_name: &str) -> Result<String,
message: "Invalid parameter value: '?' is not allowed.".to_string(),
details: None,
hint: None,
trace: None,
trace: None,
});
}
if value.contains('#') {
Expand All @@ -242,7 +242,7 @@ pub fn encode_url_path_segment(value: &str, param_name: &str) -> Result<String,
message: "Invalid parameter value: '#' is not allowed.".to_string(),
details: None,
hint: None,
trace: None,
trace: None,
});
}
if value.bytes().any(|b| b < 0x20 || b == 0x7f) {
Expand All @@ -251,7 +251,7 @@ pub fn encode_url_path_segment(value: &str, param_name: &str) -> Result<String,
message: "Invalid parameter value: control characters are not allowed.".to_string(),
details: None,
hint: None,
trace: None,
trace: None,
});
}

Expand Down
Loading