Skip to content

chore(components) Mark some fields as optional #64

Open
scanoss-qg wants to merge 3 commits intomainfrom
HideMissingValues
Open

chore(components) Mark some fields as optional #64
scanoss-qg wants to merge 3 commits intomainfrom
HideMissingValues

Conversation

@scanoss-qg
Copy link
Contributor

@scanoss-qg scanoss-qg commented Mar 4, 2026

On components status service, some fields were marked as optional
This is for hiding missing values on error scenarios:
Invalid purl -> Show only invalid purl
Invalid version -> Show invalid version and error code but nothing related to required information. Component status is still shown
Component not foud -> Only component name and error messages
And other similar scenarios..

Summary by CodeRabbit

  • Improvements
    • API responses now treat several component and version status fields as optional, allowing more flexible/tolerant responses.
    • Timestamp field for status updates renamed from "check_date" to "status_change_date" across component and version status payloads; response examples updated accordingly.
  • Documentation
    • Changelog updated with a new 0.31.1 entry documenting these fixes and example changes.

@scanoss-qg scanoss-qg requested a review from eeisegn March 4, 2026 10:01
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Rename check_date to status_change_date and make several string fields optional in VersionStatus and ComponentStatus; update Protobuf examples, generated Swagger JSON, and CHANGELOG to reflect the new field and optional semantics.

Changes

Cohort / File(s) Summary
Protobuf schema
protobuf/scanoss/api/components/v2/scanoss-components.proto
Make multiple string fields optional in VersionStatus and ComponentStatus, remove check_date, add status_change_date, and adjust example payloads and field ordering/indices.
Swagger / API docs
protobuf/scanoss/api/components/v2/scanoss-components.swagger.json
Replace check_date with status_change_date in schemas and examples; add status_change_date property and update titles/examples.
Changelog
CHANGELOG.md
Add Unreleased v0.31.1 entry documenting optional field changes and the check_datestatus_change_date rename; add comparison link for v0.31.1.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • eeisegn

Poem

🐰 I nibble at fields with careful grace,

check_date hops off, status_change takes its place,
Optional leaves flutter in a gentle breeze,
Protobuf refreshed, the schema sleeps at ease,
A rabbit's cheer — small change, big pace!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes marking fields as optional, but the main change also involves renaming check_date to status_change_date, which is a breaking API change not reflected in the title. Update the title to reflect both changes: 'chore(components) Mark fields optional and rename check_date to status_change_date' or similar to capture the full scope of modifications.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch HideMissingValues

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Mar 4, 2026

Suggested Changelog Entries

Based on the changes in this PR, here are the suggested entries for the [Unreleased] section of CHANGELOG.md:

```markdown

[Unreleased]

Changed

  • Marked status, repository_status, indexed_date, and check_date fields as optional in ComponentStatusResponse.VersionStatus message to allow these fields to be omitted from responses in error scenarios
  • Marked status, repository_status, first_indexed_date, and last_indexed_date fields as optional in ComponentStatusResponse.ComponentStatus message to allow these fields to be omitted from responses in error scenarios
    ```

@scanoss-qg scanoss-qg requested a review from agustingroh March 5, 2026 19:01
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
CHANGELOG.md (1)

11-12: Tighten changelog wording and code-span usage.

Current phrasing is a bit awkward and combines two identifiers in one code span.

Suggested text cleanup
-- Marked as optional information several keys for `ComponentStatus and VersionStatus`
-- Renamed `check_date` to `status_change_date` on `ComponentStatus and VersionStatus`
+- Marked several `ComponentStatus` and `VersionStatus` keys as optional for error scenarios
+- Renamed `check_date` to `status_change_date` in `ComponentStatus` and `VersionStatus`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 11 - 12, Change the awkward changelog phrasing and
separate code spans for identifiers: reword the two lines to use clear prose and
put each symbol in its own code span (e.g., refer to `ComponentStatus` and
`VersionStatus` individually), and rename the field text to show the rename from
`check_date` to `status_change_date` with each identifier in its own code span;
ensure the first line reads something like "Marked several keys as optional for
`ComponentStatus` and `VersionStatus`" and the second reads "Renamed
`check_date` to `status_change_date` on `ComponentStatus` and `VersionStatus`."
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Line 9: The changelog entry "## [0.31.1]" is missing its link-reference
definition; add a compare-link reference named "[0.31.1]:" matching the style
used by other versions and place it with the other link references (typically at
the bottom). The reference should point to the repository compare URL for the
previous tag to this tag (e.g., .../compare/v0.31.0...v0.31.1) and follow the
exact formatting of existing references so the "## [0.31.1]" heading resolves
correctly.
- Around line 9-12: The CHANGELOG entry for [0.31.1] is missing its reference
link and contains an incorrect claim about renaming check_date to
status_change_date; add the missing reference line "[0.31.1]:
https://github.com/scanoss/papi/compare/v0.31.0...v0.31.1" to the references
section, and update the release notes for ComponentStatus and VersionStatus to
accurately reflect the real change (e.g., remove the "Renamed `check_date` to
`status_change_date`" sentence or replace it with a correct description such as
"ensured `status_change_date` exists" or "no-op—field already named
`status_change_date`" after verifying the proto definitions) so the text matches
the codebase.

---

Nitpick comments:
In `@CHANGELOG.md`:
- Around line 11-12: Change the awkward changelog phrasing and separate code
spans for identifiers: reword the two lines to use clear prose and put each
symbol in its own code span (e.g., refer to `ComponentStatus` and
`VersionStatus` individually), and rename the field text to show the rename from
`check_date` to `status_change_date` with each identifier in its own code span;
ensure the first line reads something like "Marked several keys as optional for
`ComponentStatus` and `VersionStatus`" and the second reads "Renamed
`check_date` to `status_change_date` on `ComponentStatus` and `VersionStatus`."

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0a5a8fb5-a2c7-4479-9c5e-f2d00ed82d1c

📥 Commits

Reviewing files that changed from the base of the PR and between 44b39fc and ab23a6d.

⛔ Files ignored due to path filters (1)
  • api/componentsv2/scanoss-components.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (3)
  • CHANGELOG.md
  • protobuf/scanoss/api/components/v2/scanoss-components.proto
  • protobuf/scanoss/api/components/v2/scanoss-components.swagger.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • protobuf/scanoss/api/components/v2/scanoss-components.proto

Comment on lines +9 to +12
## [0.31.1] - 2026-03-05
### Fixed
- Marked as optional information several keys for `ComponentStatus and VersionStatus`
- Renamed `check_date` to `status_change_date` on `ComponentStatus and VersionStatus`
Copy link

@coderabbitai coderabbitai bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# List the repository structure to understand layout
echo "=== Repository structure ==="
git ls-files | head -30

# Find proto, swagger, or API definition files
echo -e "\n=== Searching for contract files ==="
fd -e proto -e swagger.json -e swagger.yaml -e openapi.json -o --type f

# Find CHANGELOG and related files
echo -e "\n=== Changelog and release files ==="
fd -i changelog -o --type f | head -20

Repository: scanoss/papi

Length of output: 1273


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for ComponentStatus and VersionStatus definitions
echo "=== ComponentStatus and VersionStatus in proto files ==="
rg -n 'message (ComponentStatus|VersionStatus)' --type-list | head -5
rg -n 'message (ComponentStatus|VersionStatus)' -A 20

# Search for check_date and status_change_date occurrences
echo -e "\n=== Occurrences of check_date and status_change_date ==="
rg -n 'check_date|status_change_date'

# Look for backward compatibility hints (deprecated, json_name, reserved)
echo -e "\n=== Backward compatibility markers ==="
rg -n 'deprecated|json_name|reserved' -B 2 -A 2 | grep -E '(check_date|status_change_date|ComponentStatus|VersionStatus)' -B 5 -A 5

Repository: scanoss/papi

Length of output: 519


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find all .proto source files
echo "=== Proto source files ==="
find . -name "*.proto" -type f

# Check for a proto directory
echo -e "\n=== Directory structure of api/ ==="
ls -la api/ 2>/dev/null | head -20

Repository: scanoss/papi

Length of output: 1616


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for ComponentStatus and VersionStatus in proto compiled files
echo "=== ComponentStatus definition ==="
rg -n 'type ComponentStatus' api/

# Search for check_date and status_change_date
echo -e "\n=== check_date and status_change_date occurrences ==="
rg -n 'check_date\|status_change_date'

# Look at full CHANGELOG to understand link structure
echo -e "\n=== CHANGELOG.md content (check for [0.31.1] reference) ==="
cat CHANGELOG.md

Repository: scanoss/papi

Length of output: 427


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Examine the proto source for ComponentStatus and VersionStatus
echo "=== scanoss-components.proto - ComponentStatus and VersionStatus ==="
rg -n 'message ComponentStatus|message VersionStatus' -A 15 ./protobuf/scanoss/api/components/v2/scanoss-components.proto

# Look for any field called check_date or status_change_date in proto
echo -e "\n=== Fields in ComponentStatus/VersionStatus ==="
rg -n 'check_date|status_change_date|reserved|json_name' ./protobuf/scanoss/api/components/v2/scanoss-components.proto

Repository: scanoss/papi

Length of output: 5267


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the CHANGELOG.md to check link references and context
echo "=== Full CHANGELOG.md ==="
cat CHANGELOG.md

Repository: scanoss/papi

Length of output: 13344


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Double-check: search in all files including pb.go for check_date
echo "=== Comprehensive search for 'check_date' in entire repository ==="
rg 'check_date' . || echo "No results found for check_date"

# Verify the missing [0.31.1] link at bottom of CHANGELOG
echo -e "\n=== End of CHANGELOG.md (last 20 lines) ==="
tail -20 CHANGELOG.md

Repository: scanoss/papi

Length of output: 1594


Add missing [0.31.1] version reference link to CHANGELOG.

The version [0.31.1] is referenced in the header but not defined in the reference links section at the end of the file. Add:

[0.31.1]: https://github.com/scanoss/papi/compare/v0.31.0...v0.31.1

Additionally, the changelog entry states "Renamed check_date to status_change_date," but this field rename does not appear to exist in the codebase. The proto definitions already contain status_change_date fields with no trace of a check_date field. Verify and correct the changelog description to accurately reflect the actual changes made in this version.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 9 - 12, The CHANGELOG entry for [0.31.1] is
missing its reference link and contains an incorrect claim about renaming
check_date to status_change_date; add the missing reference line "[0.31.1]:
https://github.com/scanoss/papi/compare/v0.31.0...v0.31.1" to the references
section, and update the release notes for ComponentStatus and VersionStatus to
accurately reflect the real change (e.g., remove the "Renamed `check_date` to
`status_change_date`" sentence or replace it with a correct description such as
"ensured `status_change_date` exists" or "no-op—field already named
`status_change_date`" after verifying the proto definitions) so the text matches
the codebase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scanoss-qg shoul we add this suggestion?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That text is already there! there was a typo on protobuff

Comment on lines +9 to +12
## [0.31.1] - 2026-03-05
### Fixed
- Marked as optional information several keys for `ComponentStatus and VersionStatus`
- Renamed `check_date` to `status_change_date` on `ComponentStatus and VersionStatus`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scanoss-qg shoul we add this suggestion?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
protobuf/scanoss/api/components/v2/scanoss-components.proto (1)

183-183: Add error-case examples to reflect the new optional semantics.

The examples at Line 183 and Line 238 only show populated success payloads. Given this PR’s behavior changes, add examples for invalid purl / invalid version / component-not-found where omitted keys are visible to clients.

Also applies to: 238-238

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@protobuf/scanoss/api/components/v2/scanoss-components.proto` at line 183, Add
explicit error-case examples alongside the existing success example strings in
the proto: update the existing example value (the JSON with
purl/name/version_status/component_status) and add additional example entries
demonstrating (1) invalid purl response, (2) invalid version response, and (3)
component-not-found response where optional keys are omitted so clients can see
absent fields; modify the same example metadata for the message that contains
the shown JSON (the proto "example" entry containing
"purl"/"version_status"/"component_status") at both places referenced in the PR
so each location includes one success example and the three error-case example
JSONs that show omitted keys and appropriate error info.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@protobuf/scanoss/api/components/v2/scanoss-components.proto`:
- Line 220: The generated Go proto for ComponentStatus has a mismatched JSON tag
for StatusChangeDate; regenerate the protobuf artifacts from
scanoss-components.proto (which correctly declares optional string
status_change_date = 5 [json_name = "status_change_date"]) so the
ComponentStatus struct's StatusChangeDate field JSON tag matches
"status_change_date" like VersionStatus does; run the protoc command (with the
same plugins/options you used originally) to recompile scanoss-components.proto
and replace the stale api/componentsv2/scanoss-components.pb.go output, then run
tests/formatting checks to ensure the JSON tags for StatusChangeDate in
ComponentStatus now match the proto definition.

---

Nitpick comments:
In `@protobuf/scanoss/api/components/v2/scanoss-components.proto`:
- Line 183: Add explicit error-case examples alongside the existing success
example strings in the proto: update the existing example value (the JSON with
purl/name/version_status/component_status) and add additional example entries
demonstrating (1) invalid purl response, (2) invalid version response, and (3)
component-not-found response where optional keys are omitted so clients can see
absent fields; modify the same example metadata for the message that contains
the shown JSON (the proto "example" entry containing
"purl"/"version_status"/"component_status") at both places referenced in the PR
so each location includes one success example and the three error-case example
JSONs that show omitted keys and appropriate error info.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad367be8-f84b-46ea-a268-aa51791d1e6d

📥 Commits

Reviewing files that changed from the base of the PR and between ab23a6d and c3904e0.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • protobuf/scanoss/api/components/v2/scanoss-components.proto
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

string last_indexed_date = 4 [json_name = "last_indexed_date"];
optional string last_indexed_date = 4 [json_name = "last_indexed_date"];
// Date of the last detected change
optional string status_change_date = 5 [json_name = "status_change_date"];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify proto declaration
echo "=== Proto declaration ==="
rg -n 'status_change_date|status_change_indexed_date' protobuf/scanoss/api/components/v2/scanoss-components.proto

# Verify generated Go protobuf tags
echo ""
echo "=== Generated Go protobuf tags ==="
rg -n 'StatusChangeDate|status_change_indexed_date|status_change_date' api/componentsv2/scanoss-components.pb.go

# Verify swagger/public schema field names
echo ""
echo "=== Swagger schema ==="
rg -n 'status_change_date|status_change_indexed_date' protobuf/scanoss/api/components/v2/scanoss-components.swagger.json

Repository: scanoss/papi

Length of output: 3093


Fix protobuf tag mismatch in generated Go code for ComponentStatus.

At line 793 of api/componentsv2/scanoss-components.pb.go, the StatusChangeDate field has a conflicting protobuf tag: json=status_change_indexed_date in the protobuf directive, but the JSON struct tag declares json:"status_change_date". The proto file correctly declares json_name = "status_change_date" (line 220), but the generated Go code for ComponentStatus does not match. Meanwhile, the VersionStatus struct at line 694 is correct. Regenerate the protobuf artifacts to align all generated outputs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@protobuf/scanoss/api/components/v2/scanoss-components.proto` at line 220, The
generated Go proto for ComponentStatus has a mismatched JSON tag for
StatusChangeDate; regenerate the protobuf artifacts from
scanoss-components.proto (which correctly declares optional string
status_change_date = 5 [json_name = "status_change_date"]) so the
ComponentStatus struct's StatusChangeDate field JSON tag matches
"status_change_date" like VersionStatus does; run the protoc command (with the
same plugins/options you used originally) to recompile scanoss-components.proto
and replace the stale api/componentsv2/scanoss-components.pb.go output, then run
tests/formatting checks to ensure the JSON tags for StatusChangeDate in
ComponentStatus now match the proto definition.

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.

2 participants