Skip to content

Fix manual json return#378

Open
Manar-Elhabbal7 wants to merge 2 commits into
microcks:masterfrom
Manar-Elhabbal7:fix_manual_json_return
Open

Fix manual json return#378
Manar-Elhabbal7 wants to merge 2 commits into
microcks:masterfrom
Manar-Elhabbal7:fix_manual_json_return

Conversation

@Manar-Elhabbal7
Copy link
Copy Markdown

@Manar-Elhabbal7 Manar-Elhabbal7 commented May 12, 2026

Description

This PR improves how the CreateTestResult() request payload is built by replacing manual JSON string concatenation with a structured approach using Go structs and json.Marshal().

Previously, building the JSON manually could lead to issues when values contained special characters like quotes or backslashes. This refactor makes the request generation safer and more reliable.

What changed

  • Introduced a testRequest struct to represent the API payload.
  • Replaced manual string building with json.Marshal().
  • Improved handling of complex fields using json.RawMessage.
  • Fixed a typo in ensureValidOAuth2Context.
  • Improved OAuth2 context parsing and validation.

Impact

  • Safer JSON generation
  • Better code readability and maintainability
  • Fewer potential runtime bugs from malformed payloads

before solving it

Screenshot from 2026-05-13 02-15-09

after solving it

Screenshot from 2026-05-13 02-09-49

Related issue(s) : #377

@Manar-Elhabbal7 Manar-Elhabbal7 marked this pull request as draft May 12, 2026 23:42
@Manar-Elhabbal7 Manar-Elhabbal7 force-pushed the fix_manual_json_return branch from 0b4f441 to 2bc6ca5 Compare May 12, 2026 23:44
…ing in CreateTestResult

Signed-off-by: Manar Elhabbal <manarelhabbal619@gmail.com>
@Manar-Elhabbal7 Manar-Elhabbal7 force-pushed the fix_manual_json_return branch from 2bc6ca5 to 1d4a285 Compare May 12, 2026 23:45
@Manar-Elhabbal7 Manar-Elhabbal7 marked this pull request as ready for review May 12, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant