Feature Request: Implement `__debugInfo()` on `Aws\Command` to prevent massive `var_dump` / log output
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Partire da Aws\Command e riprodurre lo scenario di example.php che esegue il dump di una AwsException contenente un command. Implementare la rappresentazione di debug ridotta richiesta per il command, preservando il nome e i dati essenziali ed evitando l'output ricorsivo di handler e modello API. Il lavoro è completato quando var_dump($e) non produce più il massiccio output annidato descritto nell'issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the feature
I would like to request implementing the magic method __debugInfo() on Aws\Command (and potentially related internal objects. e.g. Aws\HandlerList) to suppress excessively large outputs when using var_dump(), print_r().
When an exception occurs (e.g. Aws\Exception\AwsException), dumping the exception via var_dump($e) or passing it to certain loggers results in extremely large output.
This is mainly because AwsException holds an instance of Aws\Command, which references heavy nested service handlers and shape definitions.
Use Case
# example.php
require_once __DIR__ . '/vendor/autoload.php';
$s3Client = new Aws\S3\S3Client([/* ... */]);
try {
$s3Client->getObject([
'Bucket' => 'test-bucket',
'Key' => 'notfound.txt',
]);
} catch (Exception $e) {
var_dump($e);
}
Running the above script produces gigabytes of text output because var_dump recursively traverses all properties inside Command and its associated API models/handlers.
This makes print-debugging almost impossible and can easily overwhelm logging storage/buffers in production or development environments.
$ php example.php > out.txt
$ ls -l | grep out.txt
-rwxr-xr-x 1 user group 26626988124 Oct 2 13:52 out.txt
Proposed Solution
Implement __debugInfo() in Aws\Command so that only essential debug details (such as command name and passed arguments) are returned during inspection.
By defining __debugInfo(), PHP will use this reduced array for var_dump() / print_r() instead of recursively dumping all internal property references.
for example:
namespace Aws;
class Command implements CommandInterface
{
// ...
public function __debugInfo(): array
{
return [
'name' => $this->name,
'data' => $this->data,
];
}
}
Then, Output is below:
$ php example.php > out.txt
$ ls -l | grep out.txt
-rwxr-xr-x 1 user group 782744 Oct 2 13:57 out.txt
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
SDK version used
3.399.0
Environment details (Version of PHP (php -v)? OS name and version, etc.)
PHP 8.3.31/Rocky Linux 10.2
- Lingua principale
- PHP
- Stelle
- 6.2k
- Fork
- 1.3k
- Merge medio
- 2g 11h
- PR unite (30g)
- 8
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/aws-sdk-php
-
The SDK now requires PHP 8.2 or laterForse già presa @stobrien89 l’ha presa 4 giorni fa. Apertaannouncement SECURITY
aws/aws-sdk-php#3385 · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
feature-request p3
Difficoltà 3/5 Mezza giornata Idoneità per principianti 45/100
aws/aws-sdk-php#3377 ·
I maintainer di solito rispondono entro 2 giorni
-
Event stream decoder drops the final event when reading it reaches EOFForse già presa @stobrien89 l’ha presa 8 giorni fa. Apertabug
Difficoltà 3/5 Mezza giornata Idoneità per principianti 62/100
aws/aws-sdk-php#3374 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Event stream decoder reports a checksum mismatch when the checksum is read in partsForse già presa @stobrien89 l’ha presa 8 giorni fa. Apertabug investigating p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
aws/aws-sdk-php#3371 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
AssumeRoleCredentialProvider replaces non-RuntimeException failures with TypeErrorForse già presa @stobrien89 l’ha presa 9 giorni fa. Apertabug pending-release
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
aws/aws-sdk-php#3370 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di aws/aws-sdk-php
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
getgrav/grav-plugin-api#66 ·
-
frontend good first issue healthcare-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
AfyaLinkAfrica/afyalink-web#25 ·
I maintainer di solito rispondono entro 1 giorno
-
priority:medium type:chore
Difficoltà 1/5 1-3 ore Idoneità per principianti 84/100
crazy-goat/php-fpm-ng#1041 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug Status: Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno