A barebones implementation of an atproto PDS in PHP and Slim Framework 4.
pds php atproto
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: parameter error messages

Andrés Ignacio Torres (May 17, 2026, 12:59 AM -0700) 32fa5d61 9ad7b1d1

+37 -7
+6 -7
src/Application/Actions/Pds/Atproto/Identity/ResolveHandleAction.php
··· 73 73 74 74 private function validateHandle(string $handle): void 75 75 { 76 - $errorCode = 'InvalidHandle'; 77 76 $length = strlen($handle); 78 77 79 - if ($length < 3) { 80 - throw XrpcException::invalidRequest('Handle too short', $errorCode); 81 - } 82 - 83 - if ($length > 18) { 84 - throw XrpcException::invalidRequest('Handle too long', $errorCode); 78 + if ($length < 3 || $length > 18) { 79 + throw XrpcException::invalidParam( 80 + $this->actionName, 81 + 'Invalid handle', 82 + $handle 83 + ); 85 84 } 86 85 } 87 86 }
+15
src/Application/Actions/Pds/XrpcException.php
··· 54 54 ); 55 55 } 56 56 57 + public static function invalidParam( 58 + string $actionName, 59 + string $reason, 60 + string $value 61 + ): self { 62 + return self::invalidRequest( 63 + sprintf( 64 + 'Invalid %s params: %s (got "%s")', 65 + $actionName, 66 + $reason, 67 + $value 68 + ) 69 + ); 70 + } 71 + 57 72 public static function invalidRequest(string $message, string $error = 'InvalidRequest'): self 58 73 { 59 74 return new self($error, $message, StatusCodeInterface::STATUS_BAD_REQUEST);
+16
tests/Application/Actions/Pds/XrpcExceptionTest.php
··· 55 55 ); 56 56 $this->assertSame(400, $exception->getStatusCode()); 57 57 } 58 + 59 + public function testInvalidParamFormatsMessageWithValue(): void 60 + { 61 + $exception = XrpcException::invalidParam( 62 + 'com.atproto.identity.resolveHandle', 63 + 'Invalid handle', 64 + 'a' 65 + ); 66 + 67 + $this->assertSame('InvalidRequest', $exception->getError()); 68 + $this->assertSame( 69 + 'Invalid com.atproto.identity.resolveHandle params: Invalid handle (got "a")', 70 + $exception->getMessage() 71 + ); 72 + $this->assertSame(400, $exception->getStatusCode()); 73 + } 58 74 }